Drupal API

field_get_items 和 field_collection_field_get_entity

日期:2017-01-16 阅读:1223

在tvblock里,通过field_collection 模块来获得结果。

    <ul class="slides">

      <?php       
 $node = node_load($nid);
      
         $tvblock = field_get_items('node', $node, 'field_tvblock');
foreach ($tvblock as $key => $v2) {
                   $item = field_collection_field_get_entity($v2);
                  // pre($item);    
          $title = isset($item->field_title['und'][0]['value']) ? $item->field_title['und'][0]['value'] : '';         
           $linkurl = isset($item->field_linkurl['und'][0]['value']) ? $item->field_linkurl['und'][0]['value'] : '';
          // $blockbody = isset($item->field_blockbody['und'][0]['value']) ? $item->field_blockbody['und'][0]['value'] : '';
      
          if(isset($item->field_image['und'][0]['uri']))
          {   $image =  $item->field_image['und'][0]['uri'];
             $image = file_create_url($image);//大图片 
           }
         else $image ='';


  echo '<li>';
           if($linkurl<>'')    echo '<a target="_blank" title="'.$title.'" href="'.$linkurl.'">';
          
            echo '<img src="'.$image.'" alt="'.$title.'" />';
             if($linkurl<>'')   echo '</a>';

             print '<p class="flex-caption">'.$title.'</p>';
             echo '</li>';
         }

         ?>
   
          
        </ul>

 

<<点击返回

Drupal7视频教程 Drupal7主题 Drupal7最新文档 Drupal7推荐文档