YT Low Posted February 14, 2014 Share Posted February 14, 2014 (edited) 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 February 14, 2014 by YT Low (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted February 14, 2014 Share Posted February 14, 2014 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 More sharing options...
YT Low Posted February 14, 2014 Author Share Posted February 14, 2014 Hi vekia, Thanks for your replied. I'm beginner of PHP, would you mind to show me how to create the variable in contact controller? Thanks in advanced! Link to comment Share on other sites More sharing options...
vekia Posted February 15, 2014 Share Posted February 15, 2014 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 More sharing options...
YT Low Posted February 16, 2014 Author Share Posted February 16, 2014 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 More sharing options...
vekia Posted February 16, 2014 Share Posted February 16, 2014 where you pasted code that i suggested to use? can you show it please/ or just attach your file, i will test it on my own Link to comment Share on other sites More sharing options...
Sharak Posted June 11, 2014 Share Posted June 11, 2014 $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 More sharing options...
rogerfrilans Posted December 26, 2014 Share Posted December 26, 2014 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now