2

I have a pretty simple view in D7:

Fields

  • nid
  • title

Contextual Filters

  • nid
  • date (from date, monthly granularity)

Now I'd like to fetch some results for a specific node, but across multiple months. I was hoping to be able to pass in the contextual filter arguments via the url like so:

123/201302+201303

This isn't working for me though. Is this even possible with Date fields in Views ? I heard it was only possible with term ids right now.

Are there other techniques to accomplish this? Perhaps hook_views_query_alter() is in order here.

2
  • 1
    did you try views_embed_view('viewname', 'display_name', array(123,'201302+201303'))?
    – sel_space
    Commented Feb 26, 2013 at 23:19
  • Thanks for the suggestion about views_embed_view, I will give that a try next time. For now, I ended up just going with a hook_views_query_alter and modifying the where condition to span across both months. I did this because I am using Panels to place the view on the page, and didn't want to render the view via code. Commented Feb 27, 2013 at 16:54

1 Answer 1

0

Try with the following method using views_embed_view():

views_embed_view('viewname', 'display_name', array(123,'201302+201303'));

Or by using a hook_views_query_alter and modifying the where condition to span across both months.

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.