1

I'm trying to style a view a certain way on the front page (using a custom front page, page--front.tpl.php) of my site, and here are the steps I've taken using Entity View Types and Views modules:

1.) Created content type called 'Recipe' 2.) Created View Mode called 'Front Small' 3.) Created a view and called it 'Front Feature One' 4.) In the view settings, I've set the format to 'Content', and selected 'Front Small' view mode for display 5.) In my template.tpl.php file I've put in the following:

if ($variables['view_mode'] == 'front_small') {
    $variables['theme_hook_suggestions'] = 'node__' . $variables['type'] . $variables['view_mode'];
}

6.) I tried creating a file called node--recipe--front-small.tpl.php to style the node in a custom way but it never gets used. The standard node.tpl.php file is being used instead.

Can anyone tell me if I'm naming the file incorrectly or if something else might be wrong? When I spit out the $view_mode variable in my node file it shows "front_small" only. I've also tried removing 'recipe' from that file name to see if it would make a difference, but to no avail.

Note: I am using a custom front page styled in the page--front.tpl.php file. The view mode above that I'm trying to style should be appearing on this front page, so I'm not sure if there are other things I am missing.

Any help is greatly appreciated. Thanks in advance!

2 Answers 2

0

First of all, tell me where do you put that code? what is its function? node_preprocess? besides that It doesn't make any sense to define a specific view mode for your view then trying to theme it using views! I recommend you to define fields as view mode, select your fields and theme it in the theme hook suggestion.

0

template.tpl.php

wrong file I guess, theme hook suggestions go in template.php, you'll have to implement hook_preprocess_node(). See How to provide template for particular view mode? for an example.

The rest looks all fine for now. Also try using 'rendered entity' instead of 'content' as a format in views at least once.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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