I 'm getting crazy trying to show a value of a custom field (now in core) in a sidebar block. I have tried to show it with the render function, calling directly the field, with no luck.

I have a custom content type named "content1" and a custom field named "field_test1"; I want that value to be shown on a block that will be visible while viewing the page node.

Do you have any suggestion on how to do it?


4 Answers 4


I would use the following code, to render a field.

render(field_view_field('node', $node, 'field_test1'));

Probably the best way would be to create a view, that will output the field you want. And you can create a block out of that view.

If you are new to views, heres a video tutorial on how to do it:


With views you can do pretty much without coding.


In your hook_block_view() implementation, retrieve the current node with menu_get_object(), get the field values using field_get_items() and render the first one with field_view_value().

$node = menu_get_object('node');
if ($node && $node->type === 'content1') {
  $items = field_get_items('node', $node, 'field_test1');
  if ($items) {
    $rendered_field_value = field_view_value('node', $node, 'field_test1', $items[0]);

this is the job of http://drupal.org/project/cck_blocks

when adding a filed you will need to click on available as block.

you may want to hide the display of field from manage display.

Field is available as a block, goto block administration page and place your block in your required region

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.