问题描述
{php}
$ssa = array(3,4,5,6,7,8);
$sl = array();
$this->assign('shoe_sizes',$ssa);
$this->assign('sl',$sl);
{/php}
我在smarty模板中有此php代码,但smarty不允许/建议在具有smarty3升级的模板中使用{php}标签。该脚本位于index.tpl.html中,这是我在index.tpl.html中使用它的位置:
{foreach from = $shoe_sizes item=shoe}
我想将PHP代码与tpl文件分开。我的测试环境中没有任何插件文件夹或路径。我在Google上进行了搜索,但感到困惑。
我应该创建一个名为plugin的新文件夹并在其中编写脚本吗?
这是我最近尝试过的: 在网站/products/index.tpl.html文件中;
{include file="plugins/function.shoe-size.php"}
{foreach from = $shoe_sizes item=shoe}
{if $info.return eq $shoe and $info.return|substr:0:1 != "0"}
<p style="font-weight:bold;display:inline;border-bottom:solid 1px black;">SHOE: </p>
{/if}
{/foreach}
在网站/插件/function.shoe-size.php中
<?php
/**
* Smarty plugin
*/
/**
* Smarty {url} function plugin
*
* Type: function
* Name: Shoe Size filter
*/
function smarty_function_shoeSizes() {
$shoe_sizes = array(3,8);
return $shoe_sizes;
}
?>
这是错误:
无法在以下位置加载模板'file:plugins / function.shoe-size.php' 'products / index.tpl.html'
谢谢
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)