I want alter $node_url
in node.tpl.php
inside a module not in node.tpl.php
, which hook
should I use?
1 Answer
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';
}