【问题标题】:Getting the field_image path in Drupal 7在 Drupal 7 中获取 field_image 路径
【发布时间】:2010-08-11 21:51:53
【问题描述】:

在 Drupal 6 中,我将执行以下操作以在我的节点--articles.tpl.php 页面中获取图像:

<?php
$cck_images = $node->field_image;

if (count($cck_images)>0) :
    foreach ($cck_images as $cck_image) :
        $image = theme('imagecache', 'large', $cck_image['filepath'], $cck_image['data']['alt'], $cck_image['data']['title']);
        print $image;
    endforeach;
endif;
?>

但是,在 Drupal 7 中没有 '['filepath']',我尝试使用:

<?php print_r($field_image); ?>

但变量不存在。我知道 Drupal 7 仍处于 alpha 阶段,但我们将不胜感激!

【问题讨论】:

    标签: php drupal-7


    【解决方案1】:

    试试这个:

    <?php
    $nid = 4; 
    $node = node_load($nid);
    ?>
    <img src="<?php echo render(file_create_url($node->field_image['und'][0]['uri'])); ?>" />
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-12-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多