Skip to content

Instantly share code, notes, and snippets.

@geraldvillorente
Created June 24, 2016 05:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geraldvillorente/1f8bd3d3c603ea9b191831283d344809 to your computer and use it in GitHub Desktop.
Save geraldvillorente/1f8bd3d3c603ea9b191831283d344809 to your computer and use it in GitHub Desktop.
Answer for Drupal Stackexchange #204841

So this is the hook for node view later.

function hook_node_view_alter(&$build) {
 // Code
}

To use that hook...

/**
 * Implements hook_node_view_alter().
 */
function my_module_node_view_alter(&$build) {
 // Example of how to create a variable.
 $vid = $build['body']['#object']['vid’];
 // Create a placeholder for original vid value.
 $build['body']['#object']['original_vid'] = $vid;
 // Reset the value of vid.
 $build['body']['#object']['vid’] = NEW_VALUE;
}
@geraldvillorente
Copy link
Author

@toptomatotwo I am here in Manila, Philippines

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment