2

I would like some help on how to implement the following view: A block that shows all the 'events' happening at any 'location' created by a user.

I have 'event' and 'location' content types. There is a field in the 'event' node which refers to a 'location' node (it's nid).

I am familiar with views, just not sure how to get the 'double filtering' required to show only events that have a location that is created by the user logged in. I cannot create an 'author' relationship to a contextual filter for the location or event to a simple filter, as the view displays events, not locations... Any ideas?

0

2 Answers 2

0

I would create a View of the Content Type Location (these are the nodes created by your users, right?).

  1. Create a Relationship to Author.
  2. Create a Filter to user: current and select Yes in Is the logged in user (NB: this a a regular filter, not a Contextual Filter)
  3. Create a Relationship to the Event type through its reference field to Location (NB: select Entity Reference: Referencing Entity . If you select "Require this relationship" the View will limit the Location types to only those referenced in an Event node
  4. Add any field to the View, but be sure to select the relationship you created in 3 above to show field from the Event type

That's it! Nice question!

1
  • Hi Argie, will that not create a list of locations, and not events? I am interested in a list of 'events' for which location fields are referring to the 'location' nodes created by the logged in user. Imagine a restaurant owner wanting the list of all events happening at his restaurants. Jan 9, 2016 at 17:14
0

Thanks to Argiepiano for the direction to take. Here is what I ended up doing. Quick reminder of the objective: a business owner (owning more than one places) wants to view all events created at any of his locations. Locations and events are separate content types and in the 'event' content type, there is an entity reference field to the location nodes.

  1. Create a view of content type EVENT.

  2. Create a relationship 'Entity Reference: Referenced Entity'. Call it 'location node'.

  3. Create a relationship 'Content Author'. Call it 'location author'. Add a relationship to 'location node'.

  4. Create a contextual filter 'Content: Author uid'. Add a relationship to 'location author'.

  5. In that filter, in the section 'WHEN THE FILTER VALUE IS NOT IN THE URL', select 'provide default value' and choose 'User ID from logged in user'.

I hope it helps someone in the future!

Your Answer

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

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