I have created a "related content" view but display it as a page instead of what would more traditionally be a block.

Let's say I have three content types, event, photo and speaker. Each photo and speaker node have an entity reference to an event node.

Photo ----> EVENT <---- Speaker

When I view an event node, I would like to have a link to a page that displays all of the photos that reference that event and a similar link/page to display all speakers that reference the event. I have created a view page for each of the subordinate content types (photo/speaker) that takes an event nid as an argument and displays all the nodes that reference that parent node, but there are a number of issues related to the url of these view pages which follow the structure /node/%/photos.

Aesthetically these url's are not ideal. I would prefer to have the url contain the url alias of the event node. For example /event1/photos and event2/photos etc. would all be pointing to the same view but passing the bid of the event as the argument to the view.

I am also open to the possibility that I am going about this in the wrong way so any advice would be appreciated.

4 Answers 4


You could create two new views for this. For example:

  1. Create a new page view and name it something like Event_Photos.
  2. Set the path to be something like `event/photos/%'.
  3. Add an argument of type Content:nid.
  4. Setup a relationship using the field that references the photos from the event content-type.
  5. Add a filter using the above relationship of type Content:Type = photo.
  6. You will also need to use the relationship for all your fields.
  7. In your first view, rewrite the output for the photo link to event/photos/nid.
  8. Create a second view for your other content type and follow the above steps.

It would also be possible to use a url in the form your-event-title/photos. Then you would have to change the path to %/photos and use a argument like Content:Title instead.



Saw your tweet and thought I could lend a hand:

For #1, I've used arg() many times to construct a URL of this type. This works even when the current page is an aliased page. So node/21, aliased as marks/awesome/page, will return 21 when you use arg(1). I know this is true in D6, I'm assuming it's true in D7.

For #2, you could use PHP to handle processing of the argument. Assuming you use the URL alias for the event node as the first part of your "photos" page. You could use PHP to process the argument by running a simple query to return the node id for that alias.

Hope this helps!


You can try Relation

Relation is an API module and storage model for both simple and the most complex relations between entities. The module can handle both directional and symmetrical relations very well.

The Learn Relation module screencast


It turns out the answer is simple (as it often is). The Sub-Pathauto module solves this exact problem. No configuration required. After installing and enabling the modules, my links that I pass through l() that were rendered as node/55/photos now are displayed as event1alias/photos.

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.