我想打印 taxonomy_vocabulary_11 数组的所有结果(这是 Drupal 7 站点)。如果我使用<?php print render($content['taxonomy_vocabulary_11'][0]['#title']); ?>
,我只会得到一个结果。
我已经成功地尝试过
<?php foreach ($content->taxonomy_vocabulary_11 as $key => $value): $terms = $value['#title']; ?>
<?php print $terms; ?>
<?php endforeach?>
我收到此错误:Notice: Trying to get property of non-object
现在,这是我使用开发模块(dpm($node);
)得到的输出
(object) array(
'vid' => '5178',
'uid' => '1',
'title' => 'PROYECTO',
'log' => '',
'status' => '1',
'comment' => '2',
'promote' => '0',
'sticky' => '0',
'nid' => '155',
'type' => 'jornadas',
'language' => 'und',
'created' => '1095048000',
'changed' => '1360589684',
'tnid' => '0',
'translate' => '0',
'revision_timestamp' => '1360589684',
'revision_uid' => '1',
'taxonomy_vocabulary_4' => array(),
'taxonomy_vocabulary_6' => array(
'und' => array(
array(
'tid' => '33',
'taxonomy_term' => (object) array(
'tid' => '33',
'vid' => '6',
'name' => 'Jornadas Gratuitas',
'description' => '',
'format' => NULL,
'weight' => '0',
'vocabulary_machine_name' => 'vocabulary_6',
),
),
),
),
'taxonomy_vocabulary_7' => array(
'und' => array(
array(
'tid' => '40',
'taxonomy_term' => (object) array(
'tid' => '40',
'vid' => '7',
'name' => 'Para PH',
'description' => '',
'format' => NULL,
'weight' => '-10',
'vocabulary_machine_name' => 'vocabulary_7',
),
),
),
),
'taxonomy_vocabulary_11' => array(
'und' => array(
array(
'tid' => '262',
'taxonomy_term' => (object) array(
'tid' => '262',
'vid' => '11',
'name' => 'colegios',
'description' => '',
'format' => NULL,
'weight' => '0',
'vocabulary_machine_name' => 'vocabulary_11',
),
),
array(
'tid' => '543',
'taxonomy_term' => (object) array(
'tid' => '543',
'vid' => '11',
'name' => 'derecho',
'description' => '',
'format' => NULL,
'weight' => '0',
'vocabulary_machine_name' => 'vocabulary_11',
),
),
),
),
'body' => array(
'und' => array(
array(
'value' => "
我还尝试<?php print render($content['taxonomy_vocabulary_11']); ?>
将分类法视为任何其他领域,但它不会打印任何内容。
注意:如果我去做print $content['taxonomy_vocabulary_11'];
,只需打印单词数组。
我的方法有什么问题?