Here's my situation:

I have two content types: Procedure, and Testimonial. Testimonial has an entity reference field where you can point to one or more procedures.

My goal is to create a view of testimonials with a dynamic URL like 'example.com/testimonials/procedure1', where procedure1 is the title of the node that is referenced from the testimonial. So, the idea is that this page would exclusively show testimonials that reference the procedure1 node.

So, I created the view. I added a relationship "Entity Reference: Referenced Entity". I then created a contextual filter that uses this relationship.

At this point, if I do not use a relationship in the contextual filter, I can get this working by using the following pattern: example.com/testimonials/7, where 7 is procedure1's node ID. But, I'd like to use the title in the URL- not the node ID.

Does anyone know where to go from here? Am I going about this the wrong way?

Thank you!


3 Answers 3


This is how I solved a similar problem: Create a filter on the title and use the relationship: entity. Then, in a custom module put something similar to:

    function MYMODULE_views_pre_view(&$view, &$display_id, &$args){
      switch($view->name) {
        case 'view_name':
          $value = arg(x);
          $view->display['default']->handler->options['filters'['field_name']['value'] = $value;

I'll probably go ahead and build a more universal module out of this because of how often I use it. The benefit is you can inject an argument as a filter. I use dashes for spaces and include a str_replace(); to replace dashes with spaces for the filter. You loose some validation, etc. but there's a bunch of modules that provide filters but no contextual relationship. This binds the two in a hacky way.


Try one of these modules:

They will allow you to create looking good alias 'estimonials/PROCEDURE_NAME' for pages as 'testimonials/PROCEDURE_ID'.


What about Automatic Nodetitles? http://drupal.org/project/auto_nodetitle/

Base the title on the referenced entity and then the path on the title of the Testimonial, which will be automatically set.

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.