Jump to content

Include blockcontactinfos.tpl into contact-form.tpl


Recommended Posts

Hi,

 

Actually i would like to show the my shop name, address, fax, phone and address by including /modules/blockcontactinfos/blockcontactinfos.tpl INTO contact-form.tpl

 

But the problem is, there is no info available after i included the blockcontactinfos.tpl INTO contact-form.tpl. May I know why, and how to fix that?

 

Here is the way i include the blockcontactinfos.tpl IN contact-form.tpl

 

{include file=$tpl_dir./breadcrumb.tpl}
 
<h2>{l s='Contact us'}</h2>
 
{include file=$tpl_dir./modules/blockcontactinfos/blockcontactinfos.tpl}
 
 
{if isset($confirmation)}
    <p>{l s='Your message has been successfully sent to our team.'}</p>
    <ul class="footer_links">
        <li><a href="{$base_dir}"><img class="icon" alt="" src="{$img_dir}icon/home.gif"/></a><a href="{$base_dir}">{l s='Home'}</a></li>
    </ul>
{else}
    <p class="bold">{l s='For questions about an order or for information about our products'}.</p>
    {include file=$tpl_dir./errors.tpl}
    <form action="{$request_uri|escape:'htmlall':'UTF-8'}" method="post" class="std">
        <fieldset>
            <h3>{l s='Send a message'}</h3>
            <p class="select">
                <label for="id_contact">{l s='Subject'}</label>
                <select id="id_contact" name="id_contact" onchange="showElemFromSelect('id_contact', 'desc_contact')">
                    <option value="0">{l s='-- Choose --'}</option>
                {foreach from=$contacts item=contact}
                    <option value="{$contact.id_contact|intval}" {if isset($smarty.post.id_contact) && $smarty.post.id_contact == $contact.id_contact}selected="selected"{/if}>{$contact.name|escape:'htmlall':'UTF-8'}</option>
                {/foreach}
                </select>
            </p>
            <p id="desc_contact0" class="desc_contact"> </p>
        {foreach from=$contacts item=contact}
            <p id="desc_contact{$contact.id_contact|intval}" class="desc_contact" style="display:none;">
            <label> </label>{$contact.description|escape:'htmlall':'UTF-8'}</p>
        {/foreach}
        <p class="text">
            <label for="email">{l s='E-mail address'}</label>
            <input type="text" id="email" name="from" value="{$email}" />
        </p>
        <p class="textarea">
            <label for="message">{l s='Message'}</label>
             <textarea id="message" name="message" rows="7" cols="35">{if isset($smarty.post.message)}{$smarty.post.message|escape:'htmlall':'UTF-8'|stripslashes}{/if}</textarea>
        </p>
        <p class="submit">
            <input type="submit" name="submitMessage" id="submitMessage" value="{l s='Send'}" class="button_large" />
        </p>
    </fieldset>
</form>
{/if}
 
 
 
And here is the content i got from viewing page source from front office:
 
<div id="block_contact_infos">
    <h4>Contact us</h4>
    <ul>
    </ul>
</div>
 

No company name, address, fax and number being shown. Can anyone tell me i did wrong? Thanks in advanced.

Edited by YT Low (see edit history)
Link to comment
Share on other sites

it's because you havet o define also variables to display.

this module uses these variables:

$blockcontactinfos_company

$blockcontactinfos_address

$blockcontactinfos_phone

$blockcontactinfos_email

 

and you have to define these variables in contact controller

Link to comment
Share on other sites

paste this code:
 

			$this->smarty->assign(array(
				'blockcontactinfos_company' => Configuration::get('blockcontactinfos_company'),
				'blockcontactinfos_address' => Configuration::get('blockcontactinfos_address'),
				'blockcontactinfos_phone' => Configuration::get('blockcontactinfos_phone'),
				'blockcontactinfos_email' => Configuration::get('blockcontactinfos_email')
			));

to the initContent function in your contactController:

 

 

public function initContent()

{
parent::initContent();
 
$this->assignOrderList();
 
$email = Tools::safeOutput(Tools::getValue('from',
((isset($this->context->cookie) && isset($this->context->cookie->email) && Validate::isEmail($this->context->cookie->email)) ? $this->context->cookie->email : '')));
$this->context->smarty->assign(array(
'errors' => $this->errors,
'email' => $email,
'fileupload' => Configuration::get('PS_CUSTOMER_SERVICE_FILE_UPLOAD')
));
 
 
if (($id_customer_thread = (int)Tools::getValue('id_customer_thread')) && $token = Tools::getValue('token'))
{
$customerThread = Db::getInstance()->getRow('
SELECT cm.* 
FROM '._DB_PREFIX_.'customer_thread cm
WHERE cm.id_customer_thread = '.(int)$id_customer_thread.' 
AND cm.id_shop = '.(int)$this->context->shop->id.' 
AND token = \''.pSQL($token).'\'
');
$this->context->smarty->assign('customerThread', $customerThread);
}
 
$this->context->smarty->assign(array(
'contacts' => Contact::getContacts($this->context->language->id),
'message' => html_entity_decode(Tools::getValue('message'))
));
        
$this->smarty->assign(array(
'blockcontactinfos_company' => Configuration::get('blockcontactinfos_company'),
'blockcontactinfos_address' => Configuration::get('blockcontactinfos_address'),
'blockcontactinfos_phone' => Configuration::get('blockcontactinfos_phone'),
'blockcontactinfos_email' => Configuration::get('blockcontactinfos_email')
));
 
$this->setTemplate(_PS_THEME_DIR_.'contact-form.tpl');
}
Link to comment
Share on other sites

I follow what you have suggested, paste the code above into ContactController.php. But when i refresh my contact us page, the entire page become blank, white page, don't even have page header and page footer.

 

Is that anything else i need to insert into ContactController.php?

 

Thanks for your help. Really appreciate!

Link to comment
Share on other sites

  • 3 months later...

$this->smarty... doesn't work here. Should be $this->context->smarty...

$this->context->smarty->assign(array(
	'blockcontactinfos_company' => Configuration::get('blockcontactinfos_company'),
	'blockcontactinfos_address' => Configuration::get('blockcontactinfos_address'),
	'blockcontactinfos_phone' => Configuration::get('blockcontactinfos_phone'),
	'blockcontactinfos_email' => Configuration::get('blockcontactinfos_email')
));
Link to comment
Share on other sites

  • 6 months later...

Hi,

 

I've been trying with no success to include some of the contact info into the contact_form.tpl.

 

I have put the code you mentioned previously into Contactcontroller.php:

 

$this->context->smarty->assign(array(
'blockcontactinfos_address' => Configuration::get('blockcontactinfos_address'),
'blockcontactinfos_phone' => Configuration::get('blockcontactinfos_phone'),
'blockcontactinfos_email' => Configuration::get('blockcontactinfos_email')
));

 

And then I put this into the contact_form.tpl:

{$blockcontactinfos_address} | tl. {$blockcontactinfos_phone} | {$blockcontactinfos_email}

 

Any ideas why it does nothing?

 

Roger

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...