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

blackdog’s picture

Status: Active » Postponed (maintainer needs more info)

Why is it exposed if you don't want to show it?

Militopedia’s picture

Good 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

merlinofchaos’s picture

That sounds like what arguments are used for.

Militopedia’s picture

Yes, 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

blackdog’s picture

You 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.

Militopedia’s picture

Hi 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:

#edit-uid-wrapper {
        display:none;
}

to style.css and the filter disappeared.

Thanks,
Roger

blackdog’s picture

Status: Postponed (maintainer needs more info) » Fixed

Great!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

opteronmx’s picture

Just 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

mariusilie’s picture

Version: 6.x-2.2 » 6.x-2.6

After 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?

mariusilie’s picture

never mind, I got it.

scott_earnest’s picture

Some insight?

I would imagine something in a hook_form_alter(), but what element exactly?

Thanks.

scott_earnest’s picture

Status: Closed (fixed) » Needs review

I 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.

dawehner’s picture

Status: Needs review » Fixed

You can always use hook_preprocess_views_view

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.