0

I'm attempting to add a second contextual filter to a Calendar view generated by the Calendar module.

I'm using the entity reference module to reference all my 'Events' to 'Clients'. My desired outcome is to go to a url like example.com/client/[client-nid]/calendar/month and for the calendar to only display events that reference that client.

My Event content type has an entity reference field 'Client'. In my view, I have added a Contextual Filter for this field and set it to validate against 'Content', specifying 'Client' as the content type and Filter Value Format is Node Id.

When i use this view though example.com/client/182/calendar/month I only see a calendar with a single event on it, even though there are many nodes that reference node 182. What am i doing wrong?

1 Answer 1

1

Entity reference field can not provide content id to your view through contextual filter by default. You'll need to define a relationship to your entity reference field so that view is able to pick up Client node id ( content:nid) as contextual filter.

Remove contextual filter that you have now and add relationship to the entity reference field 'Client'. Then add contextual filter to Content:nid. In relationship setting select the alias of relationship that you added previously. In the section " When filter value is not available" check 'Provide default value -> raw value from url -> path component = 2'. Also check "use path alias".

5
  • Can you explain the relationship setting? I wasn't using a relationship setting to begin with. Commented Jan 21, 2016 at 14:06
  • I've tried this out, and i've found that when my url is structured like this: clients/2016-01/calendar/month/182 I get the desired results, but when I do the opposite: clients/182/calendar/month/2016-01 I get a month display that only shows content from the current day. Is there a way to specify the order? Commented Jan 21, 2016 at 14:53
  • you have to set up page url structure in your view settings and place "%" where you contextual filter will be. I.e. like this -> "client/%/calendar/month" - is that how you doing it?
    – oksana-c
    Commented Jan 21, 2016 at 15:15
  • yeah that's exactly what i've got Commented Jan 21, 2016 at 15:18
  • for contextual filter, try -"When the filter value is not in the URL" -> Show "No Results found" and see if that fixes the issue
    – oksana-c
    Commented Jan 21, 2016 at 15:30

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.