vivianeFinance Posted April 14, 2015 Share Posted April 14, 2015 Hi, i'm new to prestashop, and i'm facing a problem after trying to display some variables in contact-form.tpl in fact i tried to print the variable $customerThread from ContactController.php using print_r($customerThread); but it doesn't print anything then i tried to print $email and it doesn't print anything. this is the code also when i'm logged in to my website my email is showing correctly in the input although i deleted the block $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') )); from ContactController.php ( init function ) this is the code where i added the print_r public function initContent() { parent::initContent(); $this->assignOrderList(); $heyy="hello there"; $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') )); print_r($email); 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); } i don't know where does the contact-form.tpl get the email value anyone has any idea about this please ? Link to comment Share on other sites More sharing options...
Tuni-Soft Posted April 14, 2015 Share Posted April 14, 2015 open the page source (CTRL + U) and you'll find the print_r outputTo output variables correctly, add them to the array in this line$this->context->smarty->assignAnd then you can use them in the tpl with same nameExample: $this->context->smarty->assign(array( 'errors' => $this->errors, 'email' => $email, 'fileupload' => Configuration::get('PS_CUSTOMER_SERVICE_FILE_UPLOAD'), 'abcd' => 'variable content' )); In the tpl {$abcd} will show "variable content" 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