0

I have a content type, Venues and a content type Events. In the Events post type, I have 'field_hosted_by' - allowing me to select the relevant venue.

On each venue page (/venue/venue-name), i'd like to create a block listing the events they are hosting – what would be the best way to do this?

I had a solution using taxonomies but this seemed inefficient, i'd rather not have to create a term for each venue, as well as a node.

  • Using Drupal 8.
1

Taxonomy terms are still entity reference fields, just like the field you have connecting your events and venue nodes. So there is no need to duplicate the same functionality.

You can list the Events referencing the Venue with a Views Block:

  1. Create Content Views with Block display listing Events
  2. Add a Contextual filter for the field_hosted_by field and configure it:
    When the filter value is NOT available
    Provide default value
    Content ID from URL
    When the filter value IS available or a default is provided
    Specify validation criteria
    Content
    Venue
  3. Save the Views and place the Block in a region of your choice to be displayed on Venue pages

You cant test the views output by entering the node ID of a venue node into Preview field, before placing the Block to test it's working.

  • I could kick myself - i've been getting frustrated as nothing was appearing in the Preview. There's a good chance I had it correct a few times. Thanks for your help! – leeboyce Nov 19 '18 at 9:35

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.