1

I have a view that shows a table of members. I would like to have an option to filter by "new members", let's say members that joined in the last month.

If I expose the field I get an input box with "-1 month" which isn't ideal. It would be better to have a "select box" with "Any" and "New Members" options. A previous DA question didn't show an answer for this option.

Alternatively, links for "All Members" and "New Members" would work for me too. If I expose the field I can make the link work. But then I have to somehow hide the text field.

Any other solutions?

0

You can create your own form controls to send his values to exposed filters. For example, create your own select list inside a exposed filters template (views-exposed-form.tpl.php). This select list can have your desired options with respective values, according is needed in the exposed filter, for example:

<select id="edit-date" class="form-select" name="date">
<option value="-1 day">New members</option>
<option value="-7 day">Members within 1 week</option>
<option value="-30 day">Members within 1 month</option>
<option value="">All members</option>
</select>

Also, if you need a more complex behavior, you can alter view's queries with query_alter hook. This answer is an example of how to use query_alter with a custom select list.

I hope information be useful.

0

for reference, I ended up hiding the exposed filter element with css and using a link in a block to get the filtered view. I used firebug to find the div of the exposed filter and then used the css_injector module to inject this css for the view page:

.views-widget-filter-created {
  display:none;
}

Another option would be to clone your view, add the filter (without exposing it) and then linking to it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.