I've watched a million videos and read a million tutorials trying to figure out how to create a new variable for use in a version of a node.tpl.php file by utilizing preprocessing functions, but can't figure out what I'm doing wrong.
First, I copied the node.tpl.php file, renamed it node--nameofnodetype.tpl.php, and saved it in my theme folder. Then, I edited the template.php file, trying different variations of the following code.
function theme_preprocess_nodename(&$variables, $hook) {
$variables['link_name'] = 'link content';
}
I flushed the cache, and when I tried printing the new variable in the new node file, I got nothing. Can anyone tell me what I'm doing wrong?
print 'goodbye'; exit();
If nothing happens, then the function is definitely not being called. If that's the case then either your template.php is not being loaded or your function name is incorrect. To test the former, move the code above OUTSIDE the function, so it'll be executed when template.php is included. – Alfred Armstrong May 14 at 7:46