I am working in Drupal 7 and I have two content types: "member charity" and "member news story." "member news story" contains a "field_charity_reference" field (a node reference) that creates a reference between the news story and the member charity the story is about. I wish to set up a view that shows all the news stories for any charity. I have set up a page view with the path /our-members/news/%. I can set a relationship on "Content: Charity Reference" that filters only nodes with a charity reference.

How do I pass the charity name from the URL, so that only "member news story" nodes with a node reference to the charity name are returned?

Note: I have tried using "content: NID" as a contextual filter, setting the relationship to "field_charity_reference" and "When the filter value is not in the url" set to provide a default value, type Raw value from URL, path component 3 and ticking "use path alias." I have also tried the above using "Content: Charity Reference," but neither of these return any results when I go to /our-members/news/example-charity-name.

  • which version of drupal? – Bernard Nandwa Jul 5 '13 at 14:50
  • Drupal 7 - Question amended – Paul Trotter Jul 5 '13 at 16:20
  • I don't think filtering by charity name is a good idea. Having nid in URL will be better even if charity name is somewhere in URL: /our-members/news/{NID}/example-charity-name – Bulat Jul 5 '13 at 20:29
  • Hi Bulat. Could you explain why you don't think filtering by the charity name is a good idea? I am using pathauto to generate nice human readable path names and deliberately don't include NIDs as they are not meaningful to the end user. It would be unfortunate to revert to NIDs in the path name, but if you really think this is the way forward I would be interested to know your reasoning. – Paul Trotter Jul 8 '13 at 9:00
  • Hi Paul, it's not the only way forward, but it's just safer to have nid in URL. This way you know for sure that URL is uniquely resolvable. Let's see what publishers are doing - economist.com/news/finance-and-economics/…; bbc.co.uk/news/world-europe-22720228. URL should not be meaningful for end users, they actually will be more happy with something like this: bbc.co.uk/news/22720228. – Bulat Jul 8 '13 at 14:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.