1

I have a simple problem that I can't seem to resolve despite everything I have tried. Googling for a answer has not turned up anything either. Here is my problem:

I have an entity A that references entity B. What I would like to do is be able to link to entity B's content (by that I mean click a link and be taken to the page the displays entity B's content). In Views you would use the "link to content" switch to accomplish this.

However here is the catch, I would like to use entity A's title as the link's text. I figured this would be an easy thing to do in Views, but no matter what I tried I can't do this.

I have tried rewriting the result in Views, but I can't find a reference to say that you want to link to entity B's url. Using the below substitution:

<a href="{{ entityB }}">{{ entityA_title }}</a>

you would get a link that looks like:

EntityB Title">EntityA Title

Where EntityB Title would link to Entity B's content and EntityA Title would link to a page that does not exist. It looks like you can't separate Entity B's title from its url - where I just want its url.

Is there a way to accomplish what I want to achieve? I figure this should be possible and straight forward to do, but apparently not.

Thanks.

1

Here's how I do this (just tested it, working):

  1. Make sure you have a relationship to Entity B added to the view.
  2. Potential gotcha: Make sure your Title field for Entity A is NOT a link already; you won't be able to use it as a title in a link rewrite if it is already a link. (If you want to rewrite a title that is already a link, you can add a second title, make the second one not a link, and then use that in your rewrite.)
  3. Add a Path field that uses the Entity B relationship. Rewrite it like <a href="{{ path }}">{{ entityA_title }}</a>
  • Thank-you!!! You don't know how many hours I wasted trying to accomplish this simple task. I never knew there was a Path field that I could use. – user5013 Nov 28 '17 at 4:01

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.