4

I want alter $node_url in node.tpl.php inside a module not in node.tpl.php, which hook should I use?

1 Answer 1

6

This is done in template_preprocess_node() in node.module on line 1451 (http://api.drupal.org/api/drupal/modules%21node%21node.module/function/template_preprocess_node/7).

function template_preprocess_node(&$variables) {
  ...
  $variables['node_url']  = url($uri['path'], $uri['options']);
  ...

You could change it to anything else in your own module in mymodule_preprocess_node() function like so:

function mymodule_preprocess_node(&$variables) {
  $variables['node_url'] = 'some/other/path';
}

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.