By CoolCow on
Hello everyone,
I want to theme a nodes by it's ID.
In other words i would like to create template files like node-1.tpl.php, node-2.tpl.php, ...
Trying to do this i defined the theme preprocess function like this:
function THEME_NAME_preprocess(&$variables, $hook) {
switch($hook) {
case 'node':
$variables['template_files'][] = 'node-' . $variables['nid'];
break;
}
return $variables;
}
But this doesn't work.
I've been searching around in the theme.inc file to understand the steps drupal goes trough in choosing the template file.
The only thing i've found is that drupal only looks in the "modules/node" directory for that file and not in my theme directory.
Now my question is:
How can i tell drupal to look in the theme directory for that file?
Comments
This
This
should be
Tried it, but doesn't make a
Tried it, but doesn't make a difference.
There are some errors in
There are some errors in variables. The following code works.
template.php:
...
Just use the specific function - template_preprocess_node...
Pimp your Drupal 8 Toolbar - make it badass.
Adaptivetheme - theming system for people who don't code.