tenuis Posted September 30, 2012 Share Posted September 30, 2012 (edited) I'm developping a prestashop module to create a new page at a given URL. I'm quite new to 1.5 development but have found an interesting french tutorial here : http://bit.ly/N1RdKh I wanted to adapt it to display a simple tpl. It's working well, but I have a problem with localization. Whenever I change language from this particular page, id_lang changes in URL, but nothing moves on the whole page. If I load another page (like home for example) and change the language then go back to my new page, it's perfectly translated. My module's structure : Content : pagestatic/pagestatic.php <?php class PageStatic extends Module { public function __construct() { $this->name = 'pagestatic'; $this->tab = 'pagestatic'; $this->version = 0.1; $this->author = 'Tenuis'; $this->displayName = $this->l('Static Pages'); $this->description = $this->l('Additionnal page'); parent :: __construct(); } public function install() { return parent::install(); } } pagestatic/controllers/front/static.php <?php class PageStaticStaticModuleFrontController extends ModuleFrontController { public function initContent() { parent::initContent(); $page = Tools::getValue('page'); $lang = Tools::getValue('id_lang'); $cookielang = $this->context->cookie->id_lang; $this->context->smarty->assign('page', $page); $this->context->smarty->assign('lang', $lang); $this->context->smarty->assign('cookielang', $cookielang); $this->setTemplate('page.tpl'); } } pagestatic/views/templates/front/page.tpl requested page = {$page}<br /> url language = {$lang} <br /> cookie language = {$cookielang} <br /> {l s='Test EN' mod='pagestatic'} Link to my page : <a href="{$link->getModuleLink('pagestatic', 'static', ['page' => 'test'])}">test page</a> Sends me here : index.php?controller=static&page=test&fc=module&module=pagestatic&id_lang=1 My page displays : requested page = test url language = 1 cookie language = 1 Test EN When I change my language to french, url changes to id_lang=4, but cookie language stays at 1 and my "Test EN" stays as it is (and nothing on the page is translated as it should be). However, when my language is changed outside of this page and I come back here, url AND cookie are 4 and "Test EN" becomes "Test FR". I'd really appreciate your help, thanks ! Edited September 30, 2012 by tenuis (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts