0

I am currently working on a radio website.
Here is the basic information to keep it simple.

I have two content types: [emission] (programme) and [podcast].
The [emision] content is merely a general presentation with the broadcasting time. The [podcast] content has a field [field_emission] in which I can make a reference to the [program] you can hear (it works with entity reference).

I have a View displaying all podcasts.
I have another display of that View, a block, shown only on the [emission] pages. I want to restrict to results of the view to all [podcast] concerned with the displayed [emission]. How should I set the contextual filters.
Here is how I tried so far. Up to now, nothing shows up. screenshot view podcast block related

1

On the View you started (Podcast Views) the Contextual filter you need to add is the Entity reference field, not the Nid.

Here are the settings for 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 (optional)
Specify validation criteria
Validator Content
Emission

Place the block on Emission nodes. The block will take the NID of the Emission node it's on, pass it to the Entity reference contextual filter to match Emission in question, and Views results will be limited to only Podcasts which reference that Emission through the field.

You don't need the Relationship unless you plan on displaying Emission information in this block, which you probably don't.


Another approach would be through the opposite side, through Emission Views, where you list Emission content type, but you don't have to display any Fields concerning Emission. Instead you'll display only the Title field of the Podcast that is referencing that Emission.

You do that by adding the Contextual filter ID (it's not the same field as above, but the settings are are the same).

And you have to add the Relationship for the Entity reference field, but the reverse one (Relate each Content with a field_emission set to the content.)!

Then you add the Title Field, but make it uses the above Relationship. This will make the Title Field show Podcast title, and not Emission title. Set its label to something like "Podcasts referencing this Emission".

Make sure to tick "Hide if empty" under "No results behavior" so nothing is output on Emission pages that have no Podcasts referencing them.

And in the end display that block on Emission pages.

  • Thank you, it works. It didn't show because of some other setting I left, concerning the request parameters. I set it back to default and now everything is fine. – Mars Jun 11 '18 at 14:15
  • I'm glad it's working :) – prkos Jun 11 '18 at 16:50

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.