I would like to print the taxonomic terms (from the field field_tags) in a block on the node view page (in the Zen subtopic).
So what I did.
template.php
function michal_preprocess_block(&$vars, $hook) {
if ( arg(0) == 'node' && is_numeric(arg(1)) ) {
$node = node_load(arg(1));
$vars['node'] = $node;
$vars['node_field_tags'] = $node->field_tags;
$vars['node_content_field_tags'] = $node->content['field_tags'];
}
}
However, when I try to type it in block.tpl.php, none of these two variables will deduce the terms of taxonomy from the field.
print render($node_content_field_tags);
print render($node_field_tags);
Do you know the Drupal function to display a taxonomy term field?
EDIT 1/13/2011 00:21 AM
As far as I understood (from this , this and which ), this code should look more / less like this
$node = node_load(arg(1));
$node_view($node) // Generates an array for rendering a node, see http://api.drupal.org/api/drupal/modules--node--node.module/function/node_view/7
$vars['node'] = $node;
and then to block.tpl.php:
render($node->content['field_tags']);
However, the contents of $ node → is null.
Do you know what I am missing?
source
share