Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.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
Drupal 逗号分隔视图列表_Drupal_Views - Fatal编程技术网

Drupal 逗号分隔视图列表

Drupal 逗号分隔视图列表,drupal,views,Drupal,Views,各位。我对视图2有问题。我有一个将行的样式设置为字段的视图(仅获取标题字段)。我想用逗号分隔的列表显示这些标题。 例如: 哈萨克斯坦、英国、中国、韩国 尝试这样做: foreach($fields['title']->content as $titles) { $zagolovki[] = $titles['view']; } $title_list = implode(', ', $zagolovki); print $title_list; 但它不起作用——论证中的错误说。请

各位。我对视图2有问题。我有一个将行的样式设置为字段的视图(仅获取标题字段)。我想用逗号分隔的列表显示这些标题。 例如:

哈萨克斯坦、英国、中国、韩国

尝试这样做:

foreach($fields['title']->content as $titles) {

$zagolovki[] = $titles['view'];

}

$title_list = implode(', ', $zagolovki);

print $title_list;

但它不起作用——论证中的错误说。请帮助我在带有逗号分隔列表的视图中显示节点标题。谢谢

但它说错误发生在哪里?nonsenz可能是对的,
$fields['title']->content
不是数组。仅用于调试,请尝试添加

print("array content: "+ is_array($fields['title']->content));
在foreach之前。如果知道$fields是一个小型嵌套结构,可以尝试

print(str_replace("\n","<br/>",print_r($fields,true));
print(str_replace(“\n”),“
”,print_r($fields,true));

要查看其中的确切内容,以便您可以验证您尝试迭代的内容实际上是可编辑的。

它说错误发生在哪里?nonsenz可能是对的,
$fields['title']->content
不是数组。仅用于调试,请尝试添加

print("array content: "+ is_array($fields['title']->content));
如果您知道$fields是一个小型嵌套结构,您可以尝试

print(str_replace("\n","<br/>",print_r($fields,true));
print(str_replace(“\n”),“
”,print_r($fields,true));

查看其中的确切内容,以便验证您尝试迭代的内容实际上是可编辑的。

我快速查看了视图模块附带的
视图字段.tpl.php
,它显示

 /*
 * - $view: The view in use.
 * - $fields: an array of $field objects. Each one contains:
 *   - $field->content: The output of the field.
 *   - $field->raw: The raw data for the field, if it exists. This is NOT output safe.
 *   - $field->class: The safe class id to use.
 *   - $field->handler: The Views field handler object controlling this field. Do not use
 *     var_export to dump this object, as it can't handle the recursion.
 *   - $field->inline: Whether or not the field should be inline.
 *   - $field->inline_html: either div or span based on the above flag.
 *   - $field->separator: an optional separator that may appear before a field.
 * - $row: The raw result object from the query, with all data it fetched.
 */

因此,我认为$fields是您应该迭代的。如果您想调试
$fields
的结构,请安装并使用或显示
$field
的内容。可以使用您编辑的模板(该模板应该是
视图/主题
文件夹中的模板之一)看看那里发生了什么。

我很快地查看了视图模块附带的
视图字段.tpl.php
,它说

 /*
 * - $view: The view in use.
 * - $fields: an array of $field objects. Each one contains:
 *   - $field->content: The output of the field.
 *   - $field->raw: The raw data for the field, if it exists. This is NOT output safe.
 *   - $field->class: The safe class id to use.
 *   - $field->handler: The Views field handler object controlling this field. Do not use
 *     var_export to dump this object, as it can't handle the recursion.
 *   - $field->inline: Whether or not the field should be inline.
 *   - $field->inline_html: either div or span based on the above flag.
 *   - $field->separator: an optional separator that may appear before a field.
 * - $row: The raw result object from the query, with all data it fetched.
 */

因此,我认为$fields是您应该迭代的。如果您想调试
$fields
的结构,请安装并使用或显示
$field
的内容。可以使用您编辑的模板(该模板应该是
视图/主题
文件夹中的模板之一)看看那里发生了什么。

我创建了这个模块:


我不太确定是否需要修改选项来创建一个逗号分隔的列表。您应该能够,如果不能,我会修复它。

我创建了这个模块:


我不太确定是否需要修改选项来创建一个逗号分隔的列表。你应该能够,如果不能,我会修复它。

你能发布更多的代码吗?这是来自模板吗?我会说
$fields['title']->content
不是数组。这是我的views-view-fields-related-posts-by-author-block-1.tpl.php模板中的所有代码。我用这种方式显示字段。你能发布更多的代码吗?这是来自模板吗?我会说
$fields['title']->content
不是数组。这是我的views-view-fields-related-posts-by-author-block-1.tpl.php模板中的所有代码。我用这种方式显示字段。