How To Overriding Drupal Views using Templates

  0 comments
Share
  1. Create a view as per your requirement.
  2. Expand the Advanced section of your view and click on "Theme: Information" link.

    Click Theme Info Image

  3. Multiple Naming options available for each field which you filtered. In general we are taking any name of "Field Content: Title (ID: title):". Copy any name of it probably last one like below image.
  4. Create a php file with name choosen from previous step. (In my case template file name will be "views-view-field--list-node-page-titles--page-1--title.tpl.php")
  5. Now click on Your field name like "Field Content: Title (ID: title):"Copy Templete Name
  6. You will find some commented text which contain the information about the theme template used for this row style, Copy that text.Click Image
  7. Add this commented text in your template file (In my case template file name will be "views-view-field--list-node-page-titles--page-1--title.tpl.php").

    Copy Code Image

  8. Add this code on the above template file

    <?php $node_obj = node_load($row->nid); print '<pre>'; print_r($node_obj); print '</pre>'; ?>

    Note:-- node_load() is used for loading existing nodes when you have the ID (nid) of that node. $node_obj is a custom variable which I have taken.

  9. Now, First open /admin/config/development/performance and hit Clear all caches button and navigate your blog page in your browser, You will found an array with node fields value.Template Image Copy
  10. Now arrange fields according to your requirement.

Add new comment