[英]how can I output the link or path with drupal views and customfield?
[英]drupal views---how to output it
print_r($ a)的结果是
views_handle_field_node Object
(
[view]=>view Object
(
[db_table] => views_view
[base_table] => node
[args] => Array
(
[0] => My entry 1
)
[use_ajax] =>
[result] => Array
(
[0] => stdClass Object
(
[nid] => 5
[node_title] => Title of a test entry
[node_revisions_body] =>
[node_revisions_format] => 1
[node_vid] => 5
[term_data_name] => My first test term name
[term_data_vid] => 1
[term_data_tid] => 1
[vocabulary_name] => Vocabulary 1
[node_revisions_vid] => 5
)
[1]=> stdClass Object
(
[nid] => 8
[node_title] => Title of a test entry
[node_revisions_body] =>
[node_revisions_format] => 1
[node_vid] => 5
[term_data_name] => My first test term name
[term_data_vid] => 1
[term_data_tid] => 1
[vocabulary_name] => Vocabulary 1
[node_revisions_vid] => 5
..
[2]..
..
如何使用一个变量的名称将[nid] => 5和[nid] => 8 ........和所有nid.i都使用,但无法工作。
$ views_handle_field_node-> $ view-> $ result []-> nid
变量名称是$a
而不是$ views_handle_field_node,所以请尝试:
$first = $a->view->result[0]->nid;
//access all of the results?
foreach ($a->view->result as $obj) {
//do something with $obj->nid;
}
如果那没有帮助,请告诉我们背景是什么? 您是否将此代码放在模块挂钩或模板文件中? 我那种情况下是什么类型的视图设置。 告诉我们“样式”和“行样式”。
$first = $views_handle_field_node->view->result[0]->nid;
//access all of the results?
foreach ($views_handle_field_node->view->result as $obj) {
//do something with $obj->nid;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.