Prestashop 1.7 set-template with header and footer

问题描述 投票:1回答:1

我正在使用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}

但现在错误就像,未定义的语言,未定义的页面等。有没有更好的方法来做到这一点,而不是重新定义所有这些?

php oop prestashop smarty
1个回答
1
投票

您还必须调用父方法,以便初始化所有标准变量。

public function initContent()
{
    parent::initContent();

    $this->context->smarty->assign(array(
      'id' => 1,
    ));

    $this->setTemplate('module:somemodules/views/templates/front/find-modules.tpl');
}
© www.soinside.com 2019 - 2024. All rights reserved.