我的内容类型,计划拥有一个或多个“地图”。
使用以下php代码,我可以获取所有链接:
<?php print render($content['field_mappe_di_riferimento']); ?>
我得到以下结果:
我想在链接之前放置内容类型为“Mappa”的图像,在“field_immagine_min”字段中输入。
这是我的内容类型的结构:
这是内容类型“Mappa”:
with:“print_r($ field_mappe_di_riferimento);”我明白了:
数组([0] =&gt;数组([nid] =&gt; 30 [访问] =&gt; 1 [节点] =&gt; stdClass对象([vid] =&gt; 30 [uid] =&gt; 1 [title] =&gt; Carta di Marignano,primo giorno,13 Settembre 1515 [log] =&gt; [status] =&gt; 1 [comment] =&gt; 1 [promote] =&gt; 1 [sticky] =&gt; 0 [nid] =&gt; 30 [type] =&gt; mappa [语言] =&gt; en [created] =&gt; 1352066743 [已更改] =&gt; 1352127342 [tnid] =&gt; 0 [翻译] =&gt; 0 [ revision_timestamp] =&gt; 1352127342 [revision_uid] =&gt; 1 [field_battaglia_di_riferimento] =&gt;数组([und] =&gt;数组([0] =&gt;数组([nid] =&gt; 2)))[field_immagine_std] =&gt;数组([und] =&gt;数组([0] =&gt;数组([fid] =&gt; 23 [alt] =&gt; [title] =&gt; [width] =&gt; 672 [height] =&gt; 554 [uid] =&gt; 1 [filename] =&gt; polesella.jpg [uri] =&gt; public://polesella_0.jpg [filemime] =&gt; image / jpeg [filesize] =&gt; 337755 [ status] =&gt; 1 [timestamp] =&gt; 1352066743 [rdf_mapping] =&gt; Array())))[field_immagine_min] =&gt;数组([und] =&gt;数组( [0] =&gt;数组([fid] =&gt; 24 [alt] =&gt; [title] =&gt; [width] =&gt; 150 [height] =&gt; 110 [uid] =&gt; 1 [filename] =&gt; polesella_small。 jpg [uri] =&gt; public://polesella_small.jpg [filemime] =&gt; image / jpeg [filesize] =&gt; 10672 [status] =&gt; 1 [timestamp] =&gt; 1352066743 [rdf_mapping] =&gt; Array())))[field_testo_opzionale] =&gt;数组([und] =&gt;数组([0] =&gt;数组([值] =&gt; pisello [格式] =&gt; [safe_value] =&gt; pisello)))[rdf_mapping] =&gt;数组([rdftype] =&gt;数组([0] =&gt; sioc:项目1 =&gt; foaf:文档)[title] =&gt;数组([谓词] =&gt;数组([0] =&gt; dc:title))[created] =&gt; Array([谓词] =&gt;数组([0] =&gt; dc:date 1 =&gt; dc:created)[datatype] =&gt ; xsd:dateTime [callback] =&gt; date_iso8601)[changed] =&gt; Array([谓词] =&gt;数组([0] =&gt; dc:modified)[datatype] =&gt; xsd:dateTime [callback] =&gt; date_iso8601)[body] =&gt;数组([谓词] =&gt;数组([0] =&gt;内容:编码))[uid] =&gt;数组([谓词] =&gt;数组([0 ] =&gt; sioc:has_creator)[type] =&gt; rel)[name] =&gt; Array([谓词] =&gt;数组([0] =&gt; foaf:name))[comment_count] =&gt;数组([谓词] =&gt;数组([0] =&gt; sioc:num_replies)[数据类型] =&gt; xsd:整数)[last_activity] =&gt;数组([谓词] =&gt;数组([0] =&gt; ; sioc:last_activity_date)[datatype] =&gt; xsd:dateTime [callback] =&gt; date_iso8601))[cid] =&gt; 0 [last_comment_timestamp] =&gt; 1352066743 [last_comment_name] =&gt; [last_comment_uid] =&gt; 1 [comment_count] =&gt; 0 [name] =&gt; ant [picture] =&gt; 0 [数据] =&gt; B:0; )))
所以我试着拿走我想拍照的节点的nid,成功了:
print ($content['field_mappe_di_riferimento']['#items'][0][nid]);
我得到30 ......
答案 0 :(得分:0)
我找到了解决方案:
$array = $content['field_mappe_di_riferimento']['#items'];
$k = 0;
foreach($array as $k => $v){
print($k);
//carico il nodo
$node = node_view(node_load($content['field_mappe_di_riferimento']['#items'][$k]['nid']));
//stampa l'img del nodo
print render($node['field_immagine_min']);
}