Помогите сформировать вывод полей в цикле

Главные вкладки

Аватар пользователя AnreeChess AnreeChess 17 апреля 2013 в 14:10

Добрый день, у меня есть код ноды, он выведен var_dump-ом, я никак не могу добраться до полей, чтобы вывести их в цикле:

  ["field_roles"]=>
  array(1) {
    ["und"]=>
    array(2) {
      [0]=>
      array(2) {
        ["tid"]=>
        string(4) "1960"
        ["taxonomy_term"]=>
        object(stdClass)#114 (9) {
          ["tid"]=>
          string(4) "1960"
          ["vid"]=>
          string(2) "16"
          ["name"]=>
          string(29) "Алексей Колайда"
          ["description"]=>
          string(113) "<p><img alt="" src="/sites/ALL/themes/autoprofi/img/user_kalayda.jpg" style="width: 99px; height: 99px;" /></p>
"

          ["format"]=>
          string(9) "full_html"
          ["weight"]=>
          string(1) "0"
          ["vocabulary_machine_name"]=>
          string(5) "roles"
          ["field_whoareyouonsite"]=>
          array(1) {
            ["und"]=>
            array(1) {
              [0]=>
              array(1) {
                ["tid"]=>
                string(4) "1950"
              }
            }
          }
          ["rdf_mapping"]=>
          array(5) {
            ["rdftype"]=>
            array(1) {
              [0]=>
              string(12) "skos:Concept"
            }
            ["name"]=>
            array(1) {
              ["predicates"]=>
              array(2) {
                [0]=>
                string(10) "rdfs:label"
                [1]=>
                string(14) "skos:prefLabel"
              }
            }
            ["description"]=>
            array(1) {
              ["predicates"]=>
              array(1) {
                [0]=>
                string(15) "skos:definition"
              }
            }
            ["vid"]=>
            array(2) {
              ["predicates"]=>
              array(1) {
                [0]=>
                string(13) "skos:inScheme"
              }
              ["type"]=>
              string(3) "rel"
            }
            ["parent"]=>
            array(2) {
              ["predicates"]=>
              array(1) {
                [0]=>
                string(12) "skos:broader"
              }
              ["type"]=>
              string(3) "rel"
            }
          }
        }
      }
      [1]=>
      array(2) {
        ["tid"]=>
        string(4) "1961"
        ["taxonomy_term"]=>
        object(stdClass)#108 (9) {
          ["tid"]=>
          string(4) "1961"
          ["vid"]=>
          string(2) "16"
          ["name"]=>
          string(29) "Кристофер Уокен"
          ["description"]=>
          string(114) "<p><img alt="" src="/sites/ALL/themes/autoprofi/img/user_photoman.jpg" style="width: 99px; height: 99px;" /></p>
"

          ["format"]=>
          string(9) "full_html"
          ["weight"]=>
          string(1) "0"
          ["vocabulary_machine_name"]=>
          string(5) "roles"
          ["field_whoareyouonsite"]=>
          array(0) {
          }
          ["rdf_mapping"]=>
          array(5) {
            ["rdftype"]=>
            array(1) {
              [0]=>
              string(12) "skos:Concept"
            }
            ["name"]=>
            array(1) {
              ["predicates"]=>
              array(2) {
                [0]=>
                string(10) "rdfs:label"
                [1]=>
                string(14) "skos:prefLabel"
              }
            }
            ["description"]=>
            array(1) {
              ["predicates"]=>
              array(1) {
                [0]=>
                string(15) "skos:definition"
              }
            }
            ["vid"]=>
            array(2) {
              ["predicates"]=>
              array(1) {
                [0]=>
                string(13) "skos:inScheme"
              }
              ["type"]=>
              string(3) "rel"
            }
            ["parent"]=>
            array(2) {
              ["predicates"]=>
              array(1) {
                [0]=>
                string(12) "skos:broader"
              }
              ["type"]=>
              string(3) "rel"
            }
          }
        }
      }
    }
  }

мне нужно вывести в цикле по 2 поля, вот в таком виде:

<?php
for($x 0$x sizeof($node->field_roles['und']); $x++){
$role_name $node->field_roles['und'][$x]['taxonomy_term']['name'];
$role_description $node->field_roles['und'][$x]['taxonomy_term']['description'];
print 
$role_name;
print 
$role_description;                                              
}
?>

мне нужны 2 поля: $node->field_roles['und'][$x]['taxonomy_term']['name']
$node->field_roles['und'][$x]['taxonomy_term']['description']

помогите плиз...
Заранее спасибо!

Комментарии

Аватар пользователя Andruxa Andruxa 17 апреля 2013 в 14:23

как связаны между собой $node->field_roles и $node->field_icons_set ?

поскольку из листинга следует, что taxonomy_term это object(stdClass), то обращаться к значениям надо так:
$node->field_icons_set['und'][$x]['taxonomy_term']->name