Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/rest/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 创建表smarty 2_Php_Smarty - Fatal编程技术网

Php 创建表smarty 2

Php 创建表smarty 2,php,smarty,Php,Smarty,我想创建一个表smarty 2 我的目标是显示类别,而不仅仅是子类别 我试着做: <{foreach from=$super item=category_parent}> <{$category_parent.title}> <{/foreach}> <pre>{$super|@print_r}</pre> 但是在我看来,我确实想要分类 您描述了您尝试的内容,但没有描述您实际得到的结果,或者您希望看到的输出(“显示类别”非

我想创建一个表smarty 2

我的目标是显示类别,而不仅仅是子类别

我试着做:

 <{foreach from=$super item=category_parent}>
 <{$category_parent.title}>
 <{/foreach}>
<pre>{$super|@print_r}</pre>


但是在我看来,我确实想要分类

您描述了您尝试的内容,但没有描述您实际得到的结果,或者您希望看到的输出(“显示类别”非常模糊,我认为您实际上没有看到子类别标题)

我假设您希望显示标题(可能每行一个),但实际上没有显示任何内容

$super可能为空-您的屏幕截图没有明确说明顶级数组存储在$super变量中

有时,通过打印相关变量的内容进行调试非常方便:

{$super|@print_r}
这样,您就可以确认该特定点/范围中的变量名

您的模板看起来非常奇怪:

{foreach from=$super item=category_parent}
<div>{$category_parent.title}</div>
{/foreach}

不会生成有效的html(如果您试图生成html)。如果您试图生成html并在浏览器中查看结果,则页面可能因html格式错误而为空,但数据可能位于原始html中。看看生成的原始html(查看源代码)

或许可以尝试以下方式:

{foreach from=$super item=category\u parent}
{$category_parent.title}
{/foreach}
Look控制台:
{foreach from=$super item=category_parent}
<div>{$category_parent.title}</div>
{/foreach}