0

I created a new view mode for comments called "cool", as shown in the image below (click the image for full size):

enter image description here

I created comment--cool.tpl.php and added it to my theme template folder.

Based on the question about Custom tpl for view mode for all contenty type, I also need to add a pre-process to my theme. I tried:

  function MyThemeName_preprocess_comment(&$vars) {
  $vars['theme_hook_suggestions'][] = 'comment__' . $vars['view_mode'];
  }

But I get an error "Undefined index: view_mode"

Seems like comments preprocess doesn't have view_mode as an argument. So I guess it's not possible to create a tpl for comments? OR is there another way?

3

With take look at Template Comment Preprocess You find out that you just need use $vars['elements']['#view_mode'] instead of $vars['view_mode'].

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.