Parag Kuhikar
Parag Kuhikar

Reputation: 485

Custom Theme template in Drupal 7

I know, if you want to check the names of the Display Output of the view page then we need to click on the Information Link near by Theme of Advance Theme of the view, it will list all the files.

After clicking on this, it will list.

Display Output : (View Machine name is add_to_cart)

views-view.tpl.php, views-view--add-to-cart.tpl.php, views-view--default.tpl.php, views-view--default.tpl.php, views-view--page.tpl.php, views-view--add-to-cart--page.tpl.php

So, could you please suggest which files should be best for creation of the Display Output template of the view page ?

Upvotes: 0

Views: 113

Answers (1)

xangy
xangy

Reputation: 1205

If you want specific theming to your page display of add_to_cart view, then choose to override views-view--add-to-cart--page.tpl.php.

I'll also want to add the importance of naming convention for templates, so that, next time, you can choose the template name yourself:

  • views-view.tpl.php: called for every view.
  • views-view--add-to-cart.tpl.php: called for only add_to_cart view.
  • views-view--default.tpl.php: called for the display: default(master display) of every view.
  • views-view--page.tpl.php: called for the display: page of every view.
  • views-view--add-to-cart--page.tpl.php: called for the display: page of only add_to_cart view. (the specific suggestions are always last)

Note:

  • Template naming suggestion flow: general to specific.
  • Also when you click the display output, you can copy the code for the template. This way you get all the variables that are available to you.

Hope this help else comment for queries.



Understanding how default, page comes in template names:

  • Within a view, you can create many displays as shown below.

enter image description here

  • Each display has a Machine Name, for eg: System display has a machine name: system_1. So, a view with system_1 display will be overrided using views-view--system-1.tpl.php. Note: the underscore('_') is replaced with hyphen('-'). The by default view display or master display in a view has a machine name: default.

enter image description here

Upvotes: 1

Related Questions