1

Here's my intention...
I have one view to output my Downloads (Downloads is set up a content type). As a field in the content type for Downloads, I have Product. The user can choose a product for which this download applies. For example, a product brochure for product A would then have Product A as it's product field.

I wouldn't want the content editor (my client) to be able to edit and control the views, I fear it'll blow her mind. So I want to create a single view, and have this view (as a block) display on every Product page. I only want the downloads for the relevant products being displayed, not every single product.

The Downloads view is set up, but at the moment it just lists every download for every product. Is there a way to try and match [field_download_product] replacement pattern with the page's title?

Could you suggest an alternative set-up to achieve this?

  • It's possible, but first, can you tell us if you're using Drupal 6 or Drupal 7? And what kind of field are you using to specify the related product on the download node form? – marcvangend Dec 22 '11 at 12:34
  • it's Drupal 7. Currently the field is a taxonomy autocomplete. The user would add a taxonomy for each page (probably the least elegant solution in the world). – Dan Hanly Dec 22 '11 at 12:48
  • Exactly, that doesn't sounds like an ideal solution. I'll add an answer for you. – marcvangend Dec 22 '11 at 14:51
3

First of all, instead of using taxonomy, I would recommend a module like Entity Reference or References to create links between 'download' and 'product' nodes. I think Entity reference is your best bet in this case, because the module page explicitly says it supports "Integration with Views (for both forward and backward references)".

Once you have defined the download-product relations, you can build your view. The key to your solution is the concept of "contextual filters". A contextual filter is a filter with a variable filter value. You will find the settings for it in the right column when editing a view. I can't give you detailed instructions because I don't have a test site with entity reference here, but you'll need to take the following steps:

  • create a view, listing nodes of type 'download' in a block
  • add a contextual filter on the entity reference field in your download nodes
  • when configuring the contextual filter, under "When the filter value is NOT available" choose "Provide default value" -> "Content ID from URL".

So what does this all mean? You now have created a view that will only display download-nodes where the entity reference value is equal to the content ID detected in the URL.

Now, try if it works by enabling the block on product pages. Good luck - I hope this helps.

|improve this answer|||||

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.