I created a view with fields. I want to print the values of the fields. So I use views-view-feilds.tpl.php . Also I created a views-view.tpl.php to show the outer html elements. I performed <?php include('views-view-fields.tpl.php'); ?> in views-view.tpl.php file. I got the output as my requirement. But I need to know if its the right method according to drupal or any other method is available?

  • I am new to drupal, So I dont know the best practices of the drupal. And I want to follow the best drupal standards :) – Vishnu Jayan Apr 11 '16 at 6:09

It can be difficult to track the way different template files are used. First, I recommend turning on theme debugging by putting this in your settings.php

$conf['theme_debug'] = TRUE;

See this documentation for more information about theme debugging: https://www.drupal.org/node/223440 The main thing to know about that option is that it will print out the file names of the templates being suggested.

For your specific question, php includes are not the mechanism by which themes reference other themes. Rather the variables in one template are often "render arrays" (arrays with a very particular structure that sets up certain template files to be called). Here is the documentation on Render arrays in Drupal 7: https://www.drupal.org/node/930760 Ultimately, changing the template file selected involves working with render arrays in one form or another.

| 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.