4

I'm trying to figure out if path aliases are even capable of what I'm trying to do, or if I need some other sort of module.

I have a content type "project" and a content type "mockup". A "project" references a User. A "mockup" references a "project". I'd like the path pattern for a mockup to look something like (I'm making up the token names, but you get the idea)

[referenced_project's_reference_user]/[referenced_project's_title]/[node:title]

Now another thing is that the project path already looks like the first part of the mockup's path:

[project's_referenced_user]/[node:title]

So I'm wondering if there's a way for a token to get the url of the referenced node or something? I was hoping you could stack tokens something like: [[related_project]:url] but that doesn't work.

If you can't tell, I'm using the "references" module.

10

You certainly can.

You need Entity and Entity Token (comes with Entity module) modules.

Clear cache after enabling them. The referencing node info will be available to you.

For the 'referencing' functionality, I use Entity Reference instead of Node Reference which will most probably be deprecated in the near future in favor of Entity Reference. (but I remember node reference info is also available in Pathauto pattern, you may try yourself)

enter image description here

  • I have tried to implement this solution, but I cannot get it to work. Would be great if you could expand on the answer to provide a step-by-step instructions on how to implement this. It is not so clear how one can get the title of the parent node for EntityRef in your example. What would the resulting alias pattern look like. – Benjen Jun 9 '15 at 3:24
3

If you have a parent-child tree hierarchy created using entity reference fields you can use:

[node:entity-reference-field:url:path]/[node:title]

You need the modules referenced in gilzero's answer above installed

0

Also note that you only get values [node:fild-entityref:title] IF your entityreference field "number of values" is set to 1.

If you use 'unlimited' or more than 1, tokens are changed to [node:fild-entityref:(0,1,2,3...):title]

In my case using the unlimited and then picking up the right item from the list(0), broke the token and the result was empty. Tried with multiple variations to get it to work but without success.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.