Output this field as a custom link replaces + (plus) with space

Created on 22 February 2019, about 6 years ago
Updated 4 April 2025, 13 days ago

The situation is as follows:

I have a view that has several entity reference fields (referencing taxonomy vocabs) as contextual filters which are set to allow multiple values. I can then go to a page like this: /my-view-url/24+34/12 and my nodes are listed and filtered properly.

Within that view output I want to provide the user with each node title and a link to another view page that includes the same arguments as the current view. For example: /my-second-view//24+34/12 where nid is the node id of each node shown in the view. To do this I have added a Content ID field to the view output fields and used 'Output this field as a custom link' with the following rewrite:

/my-second-view/{{ nid }}/{{ raw_arguments.field_vocab1_target_id }}/{{ raw_arguments.field_vocab2_target_id }}

And, the result is not exactly as expected - the url that gets output is: /my-second-view/20/24%2034/12

I have added some debug messages in views FieldPluginBase.php in renderAsLink($alter, $text, $tokens) as follows:

1444     if (empty($alter['url'])) {
1445       if (!parse_url($path, PHP_URL_SCHEME)) {
1446         // @todo Views should expect and store a leading /. See
1447         //   https://www.drupal.org/node/2423913.
1448         $alter['url'] = CoreUrl::fromUserInput('/' . ltrim($path, '/'));
1449       }
1450       else {
1451 vdpm($path, 'before'); // my debug before
1452         $alter['url'] = CoreUrl::fromUri($path);
1453 vdpm($alter['url'], 'after'); // my debug after
1454       }
1455     }

The attached image shows the transformation occurring when CoreUrl::fromUri is called. I am not quite sure what to do from here, fairly new to D8 - any help is appreciated!

🐛 Bug report
Status

Postponed: needs info

Version

11.0 🔥

Component

views.module

Created by

🇨🇦Canada joel_osc

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

Comments & Activities

Not all content is available!

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

  • 🇳🇿New Zealand quietone

    Checking in on this issue. I can't gather enough information from the issue summary to test this, maybe someone else can.

    Anyone know if this is still a problem? If there is no confirmation that this is a problem it may be closed after three months.

  • 🇨🇦Canada joel_osc

    Thanks for looking at this @quietone. The good news is that the problem as reported seems to be fixed! Closing this issue out.

Production build 0.71.5 2024