我在新的Drupal 7主题中指出一个节点,我想使用带有自定义标记的幻灯片。
我的节点有一个包含多个图像的图像字段(field_image)。
现在我可以检索生成代码:
$node = node_load($nid);
$image = $content['field_image']["#object"]->field_image;
//htmldump($image);
foreach ($image as $key=>$value) {
$output = field_view_value('node', $node, 'field_image', $image[$key], array(
'type' => 'image',
'settings' => array(
'image_style' => 'thumbnail', //place your image style here
'image_link' => 'content',
),
));
print render($output);
}
这样可行,但我不确定这是最好的方法。
1)我如何使用“建议”或“钩子”(我对这个概念不太熟悉,并且在我的template.php中默认使用了那些)
2)$content['field_image']["#object"]->field_image;
是否健全并更新证明?
编辑:
<div class="b-slick">
<div class="b-slick__slide"><img typeof="foaf:Image" src="http://localhost/blabla/pic1.jpg" width="978" height="651" alt=""></div>
<div class="b-slick__slide"><img typeof="foaf:Image" src="http://localhost/blabla/pic2.jpg" width="978" height="651" alt=""></div>
</div>
答案 0 :(得分:0)
您可以使用以下代码:
<?php
foreach ($content['field_images'] as $key=>$image):
if(is_numeric($key)):
print render($content['field_images'][$key]);
endif;
endforeach;
?>