Hello,
I would like to hide an exposed filter of a view generated by Views2. It's id is 'uid'. The html code of this filter is
<div class="views-exposed-widget">
<label>
Member </label>
<div class="views-widget">
<div class="form-item" id="edit-uid-wrapper">
<input type="text" maxlength="128" name="uid" id="edit-uid" size="60" value="TestUser" class="form-text form-autocomplete" />
<div class="description">Enter a comma separated list of user names.</div>
</div>
<input class="autocomplete" type="hidden" id="edit-uid-autocomplete" value="http://sitename.com/admin/views/ajax/autocomplete/user" disabled="disabled" /> </div>
</div>
<div class="views-exposed-widget">
<input type="submit" id="edit-submit" value="Apply" class="form-submit" />
</div>
</div>
</div>
I think this may easily be possible via css. Something like
.view-classname form {
display:none;
}
But I have not been successful yet. Or could it be done via a tpl-file? Any ideas how to do something like that?
Thanks a lot,
Roger
Comments
Comment #1
blackdog commentedWhy is it exposed if you don't want to show it?
Comment #2
Militopedia commentedGood question. I need to use the exposed filter id value (that is shown e.g. in the URL) to show only photos of a certain member. If I hide the filter I cannot use the filter id anymore. Therefore I have to enable the exposed filter but still don't want to show it up.
Cheers,
Roger
Comment #3
merlinofchaos commentedThat sounds like what arguments are used for.
Comment #4
Militopedia commentedYes, exactly. But if I hide the filter instead of using an exposed view I cannot use arguments anymore for the user.
I want to use arguments so that I can submit a username via a php template file but I don't want that a user can enter another username via the view. Hence, I would like to hide the exposed filter.
I hope it's clear now :)
Thanks,
Roger
Comment #5
blackdog commentedYou could use arguments and then call the view with PHP in a block or in your template to set the argument at call time, without it showing to the user. See #246742: Embed View :: How the heck do we embed views in nodes in D6? for examples.
Comment #6
Militopedia commentedHi blackdog,
Thanks for the link. That seems also to be a sensible way how to achieve the same result.
Meanwhile I found out how to do it via css. I just added:
to style.css and the filter disappeared.
Thanks,
Roger
Comment #7
blackdog commentedGreat!
Comment #9
opteronmx commentedJust for reference:
In 5.x, If you need to hide views exposed filters form for any reason, you can accomplish that by installing views_filterblock.module to send that form to a block, then you can set block visibility to a non existing/not in use path.
Note: module isn't still ported to 6.x
Comment #10
mariusilie commentedAfter trying this ( http://www.computerminds.co.uk/displaying-exposed-filter-form-views-drup... ), I need to hide filters on top of the view, using some php code, not CSS. The problem is that now I have two identical forms (one on top of the view and the other on a block on the sidebar). This causes some js error (I use autocomplete on the filters) because now there are two objects with the same ID on the page DOM, and the js selector is now broken (autocomplete works only on the form above the view, not in the one in the block).
Any ideeas?
Comment #11
mariusilie commentednever mind, I got it.
Comment #12
scott_earnest commentedSome insight?
I would imagine something in a hook_form_alter(), but what element exactly?
Thanks.
Comment #13
scott_earnest commentedI realize now that you can accomplish this by using a "views-view.tpl.php" and removing the $exposed section, or unsetting it. However, seems that there would be a better way by setting the $exposed value in a hook? Let me know if there are some ideas on this.
Thanks.
Comment #14
dawehnerYou can always use hook_preprocess_views_view