1

我正在研究 Prestashop 模块。在这个模块中,我有一个冗长的 html 模板。所以,我把它分解成更小的子模板。

现在,我有一个基本模板文件,其中包含我的所有子模板文件。

我的模板目录如下:

/modules/my_module/views/templates/front/base.tpl  
/modules/my_module/views/templates/front/upper_section.tpl  
/modules/my_module/views/templates/front/middle_section.tpl  
/modules/my_module/views/templates/front/bottom_section.tpl  

现在,我将上述所有模板文件包含在 base.tpl 中,如下面的代码所示:

{include file='upper_section.tpl'}  
{include file='middle_section.tpl'}  
{include file='bottom_section.tpl'}  

当我运行模块的前控制器时,prestashop 给我的错误是“无法加载模板 upper_section.tpl”。

我也尝试过为模板文件提供相对路径和绝对路径,但每次我遇到同样的错误。

谁能帮我解决这个问题?

4

2 回答 2

2

更改您的包含以包含当前文件夹中的文件。

{include file='./upper_section.tpl'}  
{include file='./middle_section.tpl'}  
{include file='./bottom_section.tpl'}
于 2016-09-06T14:51:11.423 回答
0

给你另一种方式。

{include file='module:my_module/views/upper_section.tpl'}  
于 2017-08-17T19:24:33.833 回答