无法在同一模块模板

时间:2016-09-06 08:13:46

标签: prestashop prestashop-1.6 prestashop-1.7

我正在研究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给出了错误,因为#34;无法加载模板upper_section.tpl"。

我也试过给模板文件的相对和绝对路径,但每次我得到相同的错误。

有谁可以帮我解决这个问题?

2 个答案:

答案 0 :(得分:1)

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

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

答案 1 :(得分:0)

另一种方式。

{include file='module:my_module/views/upper_section.tpl'}