逗号分隔的视图列表
每个人。我的视图 2 有问题。我有一个视图,行的样式设置为字段(只有标题字段)。我想用逗号分隔列表显示这些标题。 例如:
哈萨克斯坦、英国、中国、韩国
试图这样做:
foreach($fields['title']->content as $titles) {
$zagolovki[] = $titles['view'];
}
$title_list = implode(', ', $zagolovki);
print $title_list;
但它不起作用 - 说论证错误。请帮助我在视图中用逗号分隔列表显示节点标题。谢谢!
everyone. I've got a problem with Views 2. I have a view with row's style set to fields (Got only title field). I want to display these titles with comma separated list.
For example:
Kazakhstan, England, China, Korea
tried to do this:
foreach($fields['title']->content as $titles) {
$zagolovki[] = $titles['view'];
}
$title_list = implode(', ', $zagolovki);
print $title_list;
but it doesn't works - says error in argument. Please help me someone to display node titles in views with comma separated list. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我快速查看了视图模块附带的
views-view-fields.tpl.php
,它显示“所以我认为 $fields 是您应该迭代的内容”。如果您想调试
$fields
的结构,请安装 devel-module并使用 dpm() 或 <一个href="http://drupalcontrib.org/api/drupal/contributions--devel--devel.module/function/dsm/6" rel="nofollow">dsm() 显示<的内容代码>$字段。也许采用您编辑的模板(这应该是views 中的 view-module 模板之一/theme
文件夹)并看看那里发生了什么。I quikly took a look in the
views-view-fields.tpl.php
that comes with the views module and it saysSo I think $fields is what you should iterate over. If you want to debug the structure of your
$fields
install the devel-module and use dpm() or dsm() to display the content of$field
. Maybe take the template you edited (that should be one of the view-module templates in theviews/theme
folder) and look what happens there.但它说错误发生在哪里? nonsenz 可能是对的,
$fields['title']->content
不是数组。仅用于调试,请尝试在 foreach 之前添加。如果您知道 $fields 是一个小的嵌套结构,您可以尝试
查看其中到底包含什么,以便您可以验证您尝试迭代的内容实际上是可迭代的。
Where does it say the error occurs, though? nonsenz is probably right that
$fields['title']->content
is not an array. For debugging only, try addingbefore the foreach. If you know that $fields is a small nested structure, you can try a
to see what exactly is in it, so that you can make verify that what you're trying to iterate over is in fact iterable.
我创建了这个模块:
http://drupal.org/project/views_delimited_list
我也不是确保摆弄选项来仅创建逗号分隔的列表。你应该可以,如果你不能,我会解决它。
I've created this module:
http://drupal.org/project/views_delimited_list
I'm not too sure about fiddling with the options to create merely a comma-separated list. You should be able to, and if you can't I'll fix it.