Add custom IDs for the form elements on a Views Filter Block (can use theme override function)

EvanDonovan - June 16, 2008 - 23:45
Project:Views Filter Block
Version:5.x-1.4
Component:Code
Category:feature request
Priority:minor
Assigned:Unassigned
Status:active
Description

I added a theme override function called phptemplate_views_filterblock in order to get custom CSS IDs for each of the fieldsets in which the view's exposed filters are contained.

I copied the function's code exactly as it was in the module, adding to the first loop (foreach ($view->exposed_filter as $count => $filter) ) the following line:

'#attributes' => array('id' => 'filter-' . $count), // giving each fieldset a unique div id

Would you consider adding that to the next version of the module? Also, would there be an easy way to get the items inside the fieldsets to also have id's? That way, theming them would be ridiculously easy.

Thanks again for the great module!

#1

EvanDonovan - June 17, 2008 - 16:11
Priority:normal» minor

Today I tried taking the theme override function I wrote out of the template.php file so that I could have it in a separate file & keep template.php from getting too long. I tried to use the _phptemplate_callback function as per www.drupal.org/node/11871, but I wasn't able to get it to work.

Strangely, even after I deleted the top line (the one which said function phptemplate_views_filterblock) and deleted the closing }, it behaved differently than it had in the template.php file. It wasn't rendering the fieldsets at all.

This is why it would be nice to have the #attributes set in the module itself, so that I wouldn't have to clutter the template.php any more than necessary :) However, it's not a big issue, so I changed the priority to minor.

#2

inforeto - June 18, 2009 - 07:55

Is there a way to call phptemplate_views_filterblock for a specific view?
The phptemplate_views_display_filters_YOUR_VIEW($view) doesn't work for blocks.

 
 

Drupal is a registered trademark of Dries Buytaert.