How to : Drupal Views Custom Templating

The templates used to render the views are listed in the “Theme Information” link in the Views edition UI. You can override the templates in your theme by copying the file from the Views module folder to your theme’s folder.

But the default Views’s template are very verbose and complete. Using the unformatted style and your four fields in display order (when reading from left to right), you should end up with a markup rich enough to achieve your layout in CSS without additional PHP/HTML code.

To override a style or content for a specific view. You have to go to views, and then go to the (page/ block/ attachment) you wants, then find “Theme: information”. There you will see a list of all templates currently using (in BOLD) and the candidate (normal fonts) template files. Select which tpl.php file you want to use.

Go to views module directory (/sites/all/module/views/) and under “theme” directory you should find base tpl.php for your chosen file. Copy that file in your theme folder. Rename it on naming convention given in Theme:information (mentioned in last paragraph).

In Drupal admin interface, click “Rescan template files”. If everything is ok, the original bold tpl.php file should not be bolded anymore. Bolded one should be your newly created tpl.php. You can now style and restructure the new tpl.php file as you like.

Advertisement
This entry was posted in Uncategorized and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s