CrayFlatline Posted May 21, 2015 Share Posted May 21, 2015 I'm creating custom module with page. I have created front controller and output page. Everything is fine. But now I have to change meta title of this page and no luck. I'm trying to make $this->context->smarty->assign(array('meta_title' => 'TEST')); But it doesn't work and on the page I see default website's meta title. I have tried to do $curr_meta_title = $this->context->smarty->getTemplateVars('meta_title'); var_dump($curr_meta_title); And it outputs NULL. I think my module is processed before processing of the default meta title setting. Please help me! What I have to do to change it's behaviour and set $meta_title? Link to comment Share on other sites More sharing options...
CrayFlatline Posted May 22, 2015 Author Share Posted May 22, 2015 Problem is solved I've placed all page logic to init() instead of initContent() I created initContent() method in my module's frontController method, moved all page output code there, and now everything works 1 Link to comment Share on other sites More sharing options...
hainn84 Posted June 23, 2017 Share Posted June 23, 2017 (edited) Hi Friend, With prestashop 1.7 you can solve it following way below : on tpl file i add : {block name='head_seo_title'}[Title]{/block} and it still works well. Edited June 23, 2017 by hainn84 (see edit history) 3 Link to comment Share on other sites More sharing options...
BeComWeb Posted August 23, 2017 Share Posted August 23, 2017 (edited) Hi hainn84, I have had the same issue with a module i'm adapting and tried your solution. It works great, thanks a lot. In addition i'd say that this code seems to work only if it is placed after the {extends} directive and before the {block name='page_content'} directive, like this {extends file='page.tpl'} {block name='head_seo_title'}{l s='Page title' mod='yourmodulename'} | {$shop.name}{/block} {block name='page_content'} Need to be confirmed. Thanks again Edited April 2, 2019 by BeComWeb (see edit history) 1 Link to comment Share on other sites More sharing options...
dronedude Posted April 22, 2019 Share Posted April 22, 2019 I'm using 1.7 and I cannot set the page title in the controller. I tried moving the code to init() but that still doesn't work. Help! I spent hours trying to do this. Why is it so hard. I have this in initContent() but also tried init() $this->context->smarty->assign('meta_title',$meta_title); $this->context->smarty->assign('meta_description',$meta_description); $this->context->smarty->assign('meta_keywords',$meta_keyword); Link to comment Share on other sites More sharing options...
Busted Posted May 17, 2022 Share Posted May 17, 2022 On 4/22/2019 at 3:52 PM, dronedude said: I'm using 1.7 and I cannot set the page title in the controller. I tried moving the code to init() but that still doesn't work. Help! I spent hours trying to do this. Why is it so hard. I have this in initContent() but also tried init() $this->context->smarty->assign('meta_title',$meta_title); $this->context->smarty->assign('meta_description',$meta_description); $this->context->smarty->assign('meta_keywords',$meta_keyword); Hi, It's been a while since this question, but I had to do the same (1.7.8). In your front controller : public function getTemplateVarPage() { $page = parent::getTemplateVarPage(); $page['meta']['title'] = 'Your Title'; return $page; } 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