1

I'm having a little trouble understanding contextual filters on Drupal Views and was wondering if I could have a hand solving this problem.

I've got a content type and which allows me to add a Title, Body and a Featured Image. I want this featured image to be displayed through a Drupal View, but only when it matches the current node. If I view the Product 1 node, I only want to show the Featured Image for Product 1 and not all the other products too.

I've got a Featured Image view set up as a Block and I can successfully display this block for my allocated content type. It reads the Content: Title and the Content: Featured Image fields where the Title field is excluded from display.

How do I configure the contextual filter to restrict the Featured Image only where the currently viewed node matches the Title. Is this possible?

1 Answer 1

4

Sure - that's a lot easier in Drupal 7 / views 3 than it used to be. You're displaying this block on a node page, correct? All you need to do is add a contextual filter of 'Content: Nid' and then add a 'default value' of type 'content id from url'.

That will pull the node id from the current url and pass it as an argument to this filter, restricting the output of your view.

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.