1

I have a node repeated on the page, once for styled dropdown menu through submenuesmall view and once as node when that submenu is selected. Submenu is styled with node--view--submenuesmall.tpl.php that is OK. But same template is used for node later instead of normal node.tpl.php

If I omit that node from submenuesmall normal node.tpl.php is used.

Is that standard behaviour and how can I fix it or did I do something wrong. All modules are up to date.

0

I believe, you can handle this in template.php of your theme, using the hook - hook_preprocess_page OR hook_preprocess_node.

Here you can change the Template file which is going to be used for that particular node, but you will have to identify at what time which TPL is to be used.

| improve this answer | |
  • Thanks! I recognized the pattern in my case, if used in view, 'theme_hook_suggestions' contains 'node__view__viewname_NODENUM' and when suggestion is wrong last one is 'node__view__viewname'. So I wrote following function (p.s. I'm not PHP developer, this can probably be better) – ikxx Dec 10 '13 at 19:18
1

Solution acording to @Vaibhav tip...

// node__view__submenuessmall is used in view
// for creating block menues with images
// when same node is used in menue and on page
// wrong theme_hook_suggestion is used on page

function cuter_preprocess_node(&$variables){
 if(array_key_exists('theme_hook_suggestions',$variables))
  { 
    $lastVar = count($variables['theme_hook_suggestions'])-1;
    if($variables['theme_hook_suggestions'][$lastVar]=='node__view__submenussmall')
    {
      //dpr($variables['theme_hook_suggestions'][$lastVar]);
      $variables['theme_hook_suggestions'][$lastVar]='foobar';
      //dpr($variables['theme_hook_suggestions'][$lastVar]);
    }
  }
}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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