I have a content type called Project. In that I have a field of Node references (unlimited amount) which can be of the content type Staff and so I am using the title of these Staff nodes in the Project content type. Staff names can also have a middle initial, e.g. Sara M. Prescott which is slighty different from the generated URL (staff/sara-m-prescott).

On the Staff pages I'd like to include a view as a block to display all the Projects they are involved in. I have tried providing a default value and using the Content ID from URL and the Raw value from the URL, but nothing works. How can I get this to work with contextual filters in Views?

Comments

nevets’s picture

Do you mean when looking at the staff page for a particular staff member?

In that case you can make a block using views. By adding a contextual filter on the entity reference on Project with the it set to use the default from the "Content ID in the URL" it should list all related projects.

solerous’s picture

I needed to add the field to the contextual filter and then match it to the title via PHP:

$node = node_load(arg(1));
return $node->title;
nevets’s picture

If the you are looking at the normal page for a node, the path node/{nid} is what views sees so you can match on the nid which is more efficient.