php-在模板的load_node上的Drupal 7中访问字段值
作者:互联网
在内容类型的模板中,我正在从节点引用中加载节点.
它加载并且如果我执行print_r,我得到这个:
stdClass Object (
[vid] => 40
[uid] => 14
[title] => Cover
[log] =>
[status] => 1
[comment] => 0
[promote] => 1
[sticky] => 0
[nid] => 40
[type] => portfolio_image_main
[language] => en
[created] => 1309382711
[changed] => 1309382711
[tnid] => 0
[translate] => 0
[revision_timestamp] => 1309382711
[revision_uid] => 14
[field_portolio_image] => Array (
[en] => Array (
[0] => Array (
[fid] => 5626
[alt] =>
[title] =>
[uid] => 14
[filename] => Cover.jpg
[uri] => public://Cover.jpg
[filemime] => image/jpeg
[filesize] => 147898
[status] => 1
[timestamp] => 1309382711
)
)
)
[name] => jojo
[picture] => 0
[data] => a:1:{s:7:"contact";i:1;}
)
我试图在这里访问单个变量:
$newImagePath1 = $newImage1-> field_portfolio_image [‘en’] [0] [‘filename’];
但到目前为止,什么都没有.有什么想法吗?
解决方法:
请尝试使用以下代码
$keys = array_keys($arr[field_portolio_image][en]);
$arr[field_portolio_image][en][$keys][filename];
标签:drupal-theming,drupal,drupal-7,php 来源: https://codeday.me/bug/20191208/2089790.html