Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 292293

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

$
0
0

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!


Viewing all articles
Browse latest Browse all 292293

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>