{$category->id|escape:'htmlall':'UTF-8'}
这个聪明的代码是用于获取分类.tpl 上的id号
我们有很多类别id的example 2,6,8,10
等,在我的文件夹中有很多文件名,例如2minimum.txt, 6minimum.txt, 8minimum.txt, 10minimum.txt
等
我想使用include文件当当前类别id页面与类别id编号txt文件。
{include file='folder/2minimum.txt'} <=-
当我输入文件名时,这将非常完美,但我想像这个一样使用
{include file='folder/{$category->id|escape:'htmlall':'UTF-8'}minimum.txt'}
但它给出错误
专家需要你的帮助来解决这个
您应该使用smarty cat
将变量连接到文件名。在您的示例中,它应该看起来像:
{include file='folder/'|cat:{$category->id|escape:'htmlall':'UTF-8'}|cat:'minimum.txt'}
智能文档链接
希望有帮助,祝你今天愉快!
{include file='folder/'|cat:$category.id|cat:'minimum.txt'}
在smarty中,{}
表示{this is smarty}
。
但你写了{this is smarty{what's this?}this is smarty}
。
这是一个语法错误。
我不确定,但我认为$category->id
是php代码风格。您可以在Prestashop模板文件中找到$category.id
是一种巧妙的代码样式。
$category.id
返回数字。我认为它不需要escape
。