1

I want to implement an exposed filter in the view with a date field. I want to show two choice in select list according to the date value (upcoming events/past events). But I don't know how to achieve this using date field because it allows to choose date only. Is there any way to achieve this feature?

Thank you in advance.

2 Answers 2

4

Add a date filter.

Expose the date filter.

Select the grouped filters option

enter image description here

Scroll down and define your filters as shown in next image

enter image description here

And you are good to go. You will have an output like this

enter image description here

You can change the options to make it a drop-down too.

To fix for the UI bug in exposed filters groups:

Make sure your date module is at Version: 7.x-2.9 or later, then apply the patch exposed_grouped_filter-1876168-71.patch (https://www.drupal.org/node/1876168#comment-10344663)

7
  • Thank you Gokul. Can I ask you a question? Which version of views are you working on because I have option to select date and relative date but no place to input the value.
    – cissharp
    Commented Dec 28, 2012 at 14:19
  • I am using Views 7.x-3.5
    – Gokul N K
    Commented Dec 28, 2012 at 19:04
  • 1
    I am also using the same version but I am having problem in UI. Screenshot: skydrive.live.com/…
    – cissharp
    Commented Jan 3, 2013 at 15:11
  • 1
    From the operator dropdown select less than or greater than options, and then add the labels accordingly. That should work.
    – Gokul N K
    Commented Jan 5, 2013 at 17:51
  • 1
    I had the same problem in UI. After a lot of attempts tried to save the grouped filter as following: 1. Created the view filter and saved with the 3 initial group items with random labels (as those cannot be removed in first save). 2. Removed the group items in next save and added one with relative value now. 3. Saved the view. 4. Added the 2nd group item to the filter. The relative date input still does not appear but for some reason it took the value now. 5. Saved the view. More saves of view or re-edits in filter may be needed in between.
    – user20765
    Commented Jun 3, 2014 at 9:14
1

Remove the 3 default options (hit "Remove" link) and add them manually by using the button "Add another item". The new options will now display the field for relative date.

Hope that helps

Best

EDIT: that seemed to work but actually not... Sorry

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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