Token for link field URL

Created on 10 February 2020, almost 5 years ago
Updated 5 August 2024, 4 months ago

To my knowledge, there are no tokens available for the URL of a link field item. Only URI and title properties are available.

This patch is intended to provide a token for the URL of a link field. For example, [paragraph:field_link:url] would provide the URL from field_link on paragraph entity type. Please let me know if I missed something and it's already covered elsewhere.

Feature request
Status

Needs review

Version

1.0

Component

Code

Created by

🇺🇸United States jienckebd

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Merge request !24Issue #3112449: Token for link field URL → (Open) created by duaelfr
  • 🇳🇿New Zealand klidifia

    If the token resolves to an internal URL (e.g. an internal node selected from an autocomplete lookup), this won't render as a link.

    Have taken the 24.patch on GitLab and added:

    if (strpos($uri, '/') === 0) {
      $uri = 'internal:' . $uri;
    }
    

    Before the:

    $replacements[$original] = Markup::create($uri);
    
  • The last submitted patch, 31: token-link-support-3112449-31.patch, failed testing. View results
    - codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

  • Status changed to Needs work over 1 year ago
  • 🇳🇿New Zealand klidifia

    Unsure how to introduce path_alias into the test setup for this as TokenFieldUiTest extends TokenTestBase

  • 🇺🇸United States Webbeh Georgia, USA

    What does the patch in #34 do? How is it different than #31? Can you provide any context to what the patch fixes?

  • 🇺🇸United States bcobin

    I'm trying to write an embedded .mp3 player for a file field (displayed as a link) and Token appends "internal:" to the path, causing the player to fail. It's a site with not a ton of audio, so I'm working around it by rewriting the title to point to the file URL and using [node:field_audio_file:title] to send the URL to the player, but there should be an option to use the path without appending "internal:" to it.

    My issue seems to be related to the discussion here, so I'm passing along the use case and trying to stay in the loop. This is a Drupal 10 site and the patch looks fairly substantial, so I'll hope for a commit. Thanks!

  • 🇪🇸Spain oskar_calvo

    I'd like to know if it's posible to apply the patch to drupal 9.x and 10.x

    Thanks.

  • Status changed to Needs review 4 months ago
  • 🇮🇳India Sharique

    I've re-rolled the patch against latest release 1.15.

  • 🇫🇷France duaelfr Montpellier, France

    Rerolled MR on latest dev version.

  • Pipeline finished with Failed
    4 months ago
    Total: 163s
    #244574
  • Pipeline finished with Failed
    4 months ago
    Total: 159s
    #245430
Production build 0.71.5 2024