Tell me more ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

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

share|improve this question

1 Answer

up vote 6 down vote accepted

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';
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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