Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Right now when you load a token it comes through as a full link rather than the bare URL. It also isn't possible to change this as there's no customizable Token view mode for the Multifield entity.
Comment | File | Size | Author |
---|---|---|---|
#18 | url-n2123387-18.patch | 4.68 KB | DamienMcKenna |
Comments
Comment #1
DamienMcKennaIt'd probably just fine to have expanded token integration to have additional sub-tokens, e.g. "[entity:field_name:url]".
Comment #2
Dave ReidProbably worth warranting changing the 'default token formatter' to the plain non-linked version, which doesn't exist yet.
To customize see https://drupal.org/node/1299662 which covers that request.
Comment #3
Dave ReidAlso could help to review #1778238: Add entity property API support for the sub-tokens when using the Entity tokens module.
Comment #4
DamienMcKennaFYI I'm using the field in a Multifield which doesn't support the Tokens view mode, otherwise I wouldn't have asked.
Comment #5
DamienMcKennaI'm working on a patch to add a default_token_formatter, will post shortly.
Comment #6
DamienMcKennaRelated: #2123435: Support the Tokens view mode
Comment #7
DamienMcKennaWould this work? It adds a new url_raw formatter that runs it through check_plain() (optionally trimmed) prior to output.
Comment #8
DamienMcKennaThis replaces the check_plain() with check_url(), per discussion with Dave in IRC.
Comment #9
Dave ReidLet's name this formatter url_plain for consistency with text module. And have the label be 'Plain URL'
Comment #10
DamienMcKennaAs you wish.
Comment #11
DamienMcKennaThis version has actually been tested :) and outputs the desired plain URL.
Comment #12
Dave ReidThis prevents the string from being recognized by localize.drupal.org. We should just use $summary[] = t(...).
Missing $summary[] = ?
Comment #13
DamienMcKennaDoh! How's about this?
Comment #14
JonMcL CreditAttribution: JonMcL commentedWorked nicely for me, but very minimal testing. Using it to display the URL in some custom admin Views.
Comment #15
madar CreditAttribution: madar commentedI use it with Linked Field to navigate to an external url on an image field. Working as expected.
Comment #16
AnybodyThere is a little bug in the patch:
The @char is missing its replacement!
After that the patch may be set RTBC from my point of view. My tests were also absolutely successful.
Comment #17
AnybodyFinal note: I had to display the token display settings first, enable and set the URL field settings there, save it and disable the token display setting in the entity again to make it work.
The best solution might be to update the related settings via a hook_update, but I think that's bonus.
Comment #18
DamienMcKennaShouldn't the messages for when the strings are not trimmed be different?
Comment #19
DamienMcKennaComment #20
Anonymous (not verified) CreditAttribution: Anonymous commentedI'm using the patch from #18 with Linked Field in an Field Collection. Working as expected.
Comment #21
AnybodyComment #22
stupiddingo CreditAttribution: stupiddingo as a volunteer commentedRTBC + 1 - working well for tokens and panes in panels.