Drupal - Making 2 Links from a View Field

22 April, 2024

In a Drupal view, one of the presentation options for a selected field is to have the field be a link to its node. What if you need the label to also be a link? No problem!

Another option is to rewrite the output, so you can manually create the links using HTML, and specify the replacement pattern of [nid] for one. The only problem is that when a field is a link to its node, the URL that appears is the path alias, mydomain.com/my-content, but when using [nid] in a manually constructed link, the resulting URL is mydomain.com/node/##.

Of course, you cannot simply embed HTML in the label. With that in mind, here are the steps:

  1. Remove the field label
  2. Check the Exclude from display box
  3. Add a global text field:
<a href="mylink1">Link Text</a>[replacement_tag_of_original_field]

 

Login or Register to Comment!