I have two content types. An image content type and a photographer content type. I have linked the photographer to the image content type by using entity reference, so that each image has a reference to a photographer.

I have created a view which shows all the images. I want to be able to use a contextual filter so that when I add the photographer title field into the URL it only shows images for that photographer. I have got this to work by adding a relationship in the view to the photographer and then using the photographer title field as the contextual filter. However, it doesn't work if any spaces in the title are replaced with dashes. Is it possible to make it work so that I can replace the spaces in the photographer title field with dashes?

So for instance the URL "photos/john smith" works, but the URL "photos/john-smith" does not, and I would like the last URL to be able to work.

1 Answer 1


The usual approach for this would be to expose the images view as a block, and to show that block in the 'context' of the photographer page. In the Contextual Filter configuration for the entity reference, select 'Provide default value > Content ID from URL' under 'When the filter value is NOT available'.

This will display each photographer's gallery as a part of his page. If the URL is important, give the photographer content type a default alias of "photos/[node:title]" under "/admin/config/search/path/patterns".


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.