Smarty 部分循环数组
我正在尝试从 smarty 3 中的以下数组生成 URL 列表。因此,对于每个循环,我需要输出 [label] 和 [url]
目前我有:
{section name="foo" loop=$list.options}
{if $list.options[foo] != "names"}
{$list.options[foo].label}
{$list.options[foo].url}
{/if}
{/section}
这只是输出空行,所以它只工作了一半只是没有文字。
[list] => Array (
[type] => Table
[name] => list
[options] => Array (
[names] => Array (
[0] => id
[1] => name
[2] => url
[3] => picture
[4] => featured
)
[id] => Array (
[enabled] => 1
[label] => Id
[url] => /admin/list/desc
)
[name] => Array (
[enabled] => 0
[label] => Name
[url] => /admin/list/desc
)
[url] => Array (
[enabled] => 0
[label] => Uri
[url] => /admin/list/desc
)
[picture] => Array (
[enabled] => 0
[label] => pciture
[url] => /admin/list/desc
)
[featured] => Array (
[enabled] => 0
[label] => Featured
[url] => /admin/content/list/desc
)
)
)
I am trying to generate a list of URLs from the following array in smarty 3. So for each loop I would need to output the [label] and [url]
At the moment I have:
{section name="foo" loop=$list.options}
{if $list.options[foo] != "names"}
{$list.options[foo].label}
{$list.options[foo].url}
{/if}
{/section}
This just outputs blank lines so it is half working just no text.
[list] => Array (
[type] => Table
[name] => list
[options] => Array (
[names] => Array (
[0] => id
[1] => name
[2] => url
[3] => picture
[4] => featured
)
[id] => Array (
[enabled] => 1
[label] => Id
[url] => /admin/list/desc
)
[name] => Array (
[enabled] => 0
[label] => Name
[url] => /admin/list/desc
)
[url] => Array (
[enabled] => 0
[label] => Uri
[url] => /admin/list/desc
)
[picture] => Array (
[enabled] => 0
[label] => pciture
[url] => /admin/list/desc
)
[featured] => Array (
[enabled] => 0
[label] => Featured
[url] => /admin/content/list/desc
)
)
)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)