I have just introduced my custom template suggestions in MYTHEME_preprocess_node
, based on a certain field's value. Won't work somehow.
The content type is project
. In my template folder I have already a file named node--project.tpl.php
, and my suggestions append additional two: node--project--pcgame.tpl.php
and node--project--movie.tpl.php
. They are visible when I dpm()
the variables, but are not found/applied to the node, even when I remove node--project.tpl.php
.
Cache cleared.
Any clue as per what could be the cause?
The code I'm using:
function MYTHEME_preprocess_node($variables){
if(isset($variables['node'])){
$node = $variables['node'];
if($node->type == 'project'){
// Determine project type based on a term field.
$project_type = (int) $node->field_genre['und'][0]['tid'];
switch($project_type){
case 4:
$variables['theme_hook_suggestions'][] = 'node__project__pcgame';
break;
default:
$variables['theme_hook_suggestions'][] = 'node__project__movie';
}
dpm($variables['theme_hook_suggestions']);
}
}
}
$variables
needs to be passed by reference, i.e.function MYTHEME_preprocess_node(&$variables){
$variables
contains it :)