Smarty节循环的未定义索引通知

时间:2015-08-18 14:21:24

标签: smarty

当循环结果没有数据或MySQL数据库为空时,我的section循环出现未定义的索引错误。

代码如下:

{section name=foo loop=$data}
//data goes here
{/section}

如何在section循环中使用isset()?

使用smarty 3.1.21版本

谢谢

1 个答案:

答案 0 :(得分:1)

您应该尝试使用here

提及的default变量处理
{section name=foo loop=$data|defalut:""}
//data goes here
{/section}

如果您没有使用{sectionelse},请使用此版本。

{section name=foo loop=$data|defalut:"No data found"}
 //data goes here
{/section}

希望这会有所帮助:)

相关问题