Closed (fixed)
Project:
Views (for Drupal 7)
Version:
6.x-3.x-dev
Component:
exposed filters
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
28 Jan 2010 at 19:07 UTC
Updated:
14 Jun 2011 at 22:17 UTC
I was theming my exposed filters, and couldn't style each individual exposed filter because the divs had a class of views-exposed-widget but no unique identifier. it WAS like this (note no id in the div):
<div class="views-exposed-widget">
<label for="edit-uid">
Name </label>
<div class="views-widget"> ...
So I edited views-exposed-form.tpl.php in my modules/views/theme to look like this:
<div class="views-exposed-widget" id="<?php print $widget->id; ?>">
and now my html source looks like this (note the id in the div):
<div id="edit-uid" class="views-exposed-widget">
<label for="edit-uid">
Name </label>
<div class="views-widget"> ...
and edited my theme css to look like this:
#edit-uid.views-exposed-widget {
clear:both;
float:none;
}
where edit-uid is the unique identifier for the exposed filter I'm trying to style.
Did I do the right thing? Is there a better/easier way around this? I don't like hacking files in modules because i will need to rehack when I update the module no?
Comments
Comment #1
davidbessler commentedDarn. Now the field doesn't autocomplete. Anyone have a solution for me?
Comment #2
davidbessler commentedOK. So, clearly, I'm the kind of guy who doesn't read directions before I do something. I found this:
http://drupal.org/node/190815
clearly explaining the concept of overriding .tpl.php files. So, ignore that whole part.
I still need help figuring out how to get the autocomplete to work on my field again.
Comment #3
dawehnerWhat happens if you remove this css code? i guess this could be the reason.
Comment #4
davidbessler commentedI got it to work. I was using the same ID as other things, and CSS needs IDs to be unique. So I had the IDs come out as style-edit-uid instead of edit-uid which was being used for the labels. Now it works fine. Thanks.
Comment #5
dawehnerAh fine.
Comment #7
squarecandy commentedThanks for the reminder that views-exposed-form.tpl.php exists.
I used
id="exposed-widget-<?php print $id; ?>"instead ofid="exposed-widget-<?php print $widget->id; ?>"- some things like the date module were not providing a value for $widget->id.