Views - Replacement patterns list is not complete

Created on 26 January 2016, almost 9 years ago
Updated 21 March 2023, almost 2 years ago

I created a view with context filters and several fields. So, I expected to see them within Replacement Patterns but there were only patterns from Context Filter.

That was a disappointment, however when I tried to test Replacement Patterns which were not in the list - they worked.

The problem is within generating Replacement Pattern list:
core\modules\views\src\Plugin\views\area\TokenizeAreaPluginBase.php:81

This:

      foreach (array_keys($options) as $type) {
        if (!empty($options[$type])) {
          $items = array();
          foreach ($options[$type] as $key => $value) {
            $items[] = $key . ' == ' . $value;
          }
          $form['tokens']['tokens'] = array(
            '#theme' => 'item_list',
            '#items' => $items,
          );
        }
      }

Should be changed to this:


      $items = array();
      foreach (array_keys($options) as $type) {
        if (!empty($options[$type])) {
          foreach ($options[$type] as $key => $value) {
            $items[] = $key . ' == ' . $value;
          }
        }
      }
      $form['tokens']['tokens'] = array(
        '#theme' => 'item_list',
        '#items' => $items,
      );

$options has 2 keys: 'fields' and 'context'. And $form['tokens']['tokens'] rewrites the first 'fields' values with 'context' ones.

Problem persists for 8.1.x dev.

Please add a fix to this issue to the new version :)

🐛 Bug report
Status

Needs work

Version

10.1

Component
Views UI 

Last updated 17 days ago

Created by

🇧🇾Belarus megastruktur

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

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.

Production build 0.71.5 2024