2
votes

A while back you commented on a poster's question for how to alter the Drupal Views2 Exposed Form. In the post you mentioned:

The proper way of changing the theme would be to override the views-exposed-form.tpl file in your theme's folder. Bear in mind that this will apply to all exposed filter forms, to theme a specific one, you will need to use a different name for that filename, like:

views-exposed-form--TITLE--DISPLAY.tpl.php
views-exposed-form--TITLE.tpl.php

and some others, you can check the Theme: Information section of your views for template naming conventions.

Can you expand on what the 'TITLE' and 'DISPLAY' are exactly? Are both template files needed or just one of them?

Thanks.

2

2 Answers

5
votes

I am not the author of the post you are referring to, but I can answer this question.

The way Views theming works is that there is a base template for a specific part of the output and this base template can be made more specific by adding additional qualifiers to it.

If you copied /sites/all/modules/views/theme/views-exposed-form.tpl.php to your theme folder (or from wherever you have Views installed), made changes to the copy, and then edited your view and chose Theme: Information and clicked Rescan Template Files, Views would now use this template in your theme folder for rendering the exposed filters form. This is the base template name and so it will be used for every view's exposed filters form.

If the change you're making should be applied to every exposed filters form then you're done. However you probably want to limit this overriden template file to specific views or even specific displays of specific views. If you want to apply the template only to a view named testview then you could rename your theme's views-exposed-form.tpl.php to views-exposed-form--testview.tpl.php. Don't forget to use the Rescan Template Files button after each rename or new file. Now that template only applies to the view testview and all of its displays.

A view can have multiple displays - maybe a block, a page, a page for admins, etc. These are listed vertically down the left side of the edit page for a view. You can get more specific and target a particular display of a particular view. To do this, you might name this template file views-exposed-form--testview--page-1.tpl.php which would cause it only to be used for the testview view and only for the first page display of that view. You can find the display name by hovering over the tab - it will appear at the end of the URL your browser shows in the status (default, page_1, etc). Just remember to turn underscores to hyphens in the template filenames: use page-1 not page_1.

You can also target all pages for example: views-exposed-form--testview--page.tpl.php.

These naming conventions as well as a list of templates which can be overriden are available here: http://views.doc.logrus.com/ (click Views Template Files).

So, if you have a specific display or view where you want to override the default template then you only need a single file targeted for that combination. If you need to target additional views or display combinations, you will have more files.

0
votes

You can try Views exposed form layout module for views exposed form theming.