2013-10-07 117 views
0

我從Drupal的像這樣的陣列輸出,如何從 field_episode_tags訪問[名]的價值,我有這個迄今爲止訪問對象的另一個對象中在Drupal

print $node->field_episode_tags['und']['0']['taxonomy_term']->['name'] 

當我直到'分類術語'還有另一個對象,我嘗試使用另一個 - > poitner但沒有奏效。

stdClass Object 
    (
     [vid] => 25 
     [uid] => 1 
     [title] => Is there any cosmos theory? 
     [log] => 
     [status] => 1 
     [comment] => 1 
     [promote] => 0 
     [sticky] => 0 
     [nid] => 25 
     [type] => tv_episode 
     [language] => en 
     [created] => 1380610491 
     [changed] => 1381115053 
     [tnid] => 0 
     [translate] => 0 
     [revision_timestamp] => 1381115053 
     [revision_uid] => 1 
     [body] => Array 
      (
       [und] => Array 
        (
         [0] => Array 
          (
           [value] => summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text 
           [summary] => 
           [format] => filtered_html 
           [safe_value] => <p>summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text</p> 

           [safe_summary] => 
          ) 

        ) 

      ) 

     [field_video_category] => Array 
      (
       [und] => Array 
        (
         [0] => Array 
          (
           [tid] => 25 
          ) 

        ) 

      ) 

     [field_featured] => Array 
      (
      ) 

     [field_kaltura_video] => Array 
      (
      ) und 0 taxonomy term->name 

     [field_episode_tags] => Array 
      (
       [und] => Array 
        (
         [0] => Array 
          (
           [tid] => 95 
           [taxonomy_term] => stdClass Object 
            (
             [tid] => 95 
             [vid] => 1 
             [name] => zen 
             [description] => 
             [format] => 
             [weight] => 0 
             [vocabulary_machine_name] => tags 


         [rdf_mapping] => Array 

回答

0

您需要直接訪問實例datamember,而不使用括號[]。這些用於數組鍵。

print $node->field_episode_tags[LANGUAGE_NONE]['0']['taxonomy_term']->name