I want to add some extra information like an additional html link along with the node data at node render.

Hope I tried googling but came to know that we can do it through hook_node_view_alter, but not able to do it.

  • Hello. Please be more specific. "You should only ask practical, answerable questions based on actual problems that you face." - so what link is it? Where is it supposed to link to? Is it supposed to be editable by node's owner? Why can't you just write it in the body?
    – Mołot
    Nov 22 '13 at 10:42

You can do it with any of the following hooks:

The choice of hook would depend on the requirements and/or personal preference.

Using hook_node_view_alter():

 * Implements hook_node_view_alter().
function example_node_view_alter(&$build) {
  $build['#suffix'] = '<strong>Hello</strong>';

Using hook_node_view():

function nodeapi_example_node_view($node, $build_mode = 'full') {
  if (variable_get('nodeapi_example_node_type_' . $node->type, FALSE)) {
    // Make sure to set a rating, also for nodes saved previously and not yet rated.
    $rating = isset($node->nodeapi_example_rating) ? $node->nodeapi_example_rating : 0;
    $node->content['nodeapi_example'] = array(
      '#markup' => theme('nodeapi_example_rating', array('rating' => $rating)),
        '#weight' => -1,

(Snippet from the excellent examples module)

  • thanks angheloko..! but could you please let me know how to add the "my additional content" to the $build array returned in node_view_alter
    – Chella
    Nov 22 '13 at 10:50

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