我正在使用prestashop 1.7并为我的模块创建了一个前端控制器。当我使用setTemplate时,它不包括页眉和页脚只是一个空白页面。我已经为模块控制器分配了一个页面(在后台),在模块中,我使用以下代码:
/modules/some modules/controllers/front/modules list.PHP:
class somemodulesmoduleslistModuleFrontController extends ModuleFrontController
{
public function initContent(){
$this->context->smarty->assign(array(
'id' => 1,
));
$this->setTemplate('module:somemodules/views/templates/front/find-modules.tpl');
}
}
我在模板文件中尝试过的内容:
/modules/some modules/views/templates/front/find-modules.太平路:
{extends file='page.tpl'}
{block name='page_content'}
{{$id}}
{/block}
但现在错误就像,未定义的语言,未定义的页面等。有没有更好的方法来做到这一点,而不是重新定义所有这些?
您还必须调用父方法,以便初始化所有标准变量。
public function initContent()
{
parent::initContent();
$this->context->smarty->assign(array(
'id' => 1,
));
$this->setTemplate('module:somemodules/views/templates/front/find-modules.tpl');
}