Replacement tokens from contextual filters are showing, but the fields used in the view aren't. You can still use them, but I think it should be clear to an user that this is the case. See screenshot for details.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Nitebreed created an issue. See original summary.

neutromancer’s picture

I have the same issue, except I can't use the tokens that aren't shown.
This also happens when editing the view Title.
If I use the token before adding the Contextual Filter, it works even after I add it.
If I edit the Title, or Header and save, they stop working (displaying {{ title }} instead, for example), and I have to temporarily remove the contextual filter if I want to add these tokens again.

neutromancer’s picture

Title: Vies field token replacement patterns aren't showing when using Header: Global: Text area » Views field token replacement patterns aren't showing when using Header: Global: Text area
joachim’s picture

Version: 8.1.8 » 8.3.x-dev

This is because the code to make the list of tokens is arranging them into groups, but then clobbering each group:

      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,
          );
        }
      }

$form['tokens']['tokens'] is getting set each time, so earlier $type lists (where $type is fields, then arguments) get clobbered.

Patch coming.

joachim’s picture

Title: Views field token replacement patterns aren't showing when using Header: Global: Text area » Views field token replacement patterns aren't showing in area handlers admin form
Status: Active » Needs review
FileSize
717 bytes

Here's a patch.

This affects all area handlers that use TokenizeAreaPluginBase, so the unfiltered one too.

Lendude’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

Fix looks great, but this still needs tests.

Lendude’s picture

Version: 8.3.x-dev » 8.2.x-dev
Status: Needs work » Needs review
Issue tags: -Needs tests
FileSize
1.68 KB
2.38 KB

Test and fix.

Bug fix, so this can go against 8.2.x

The last submitted patch, 7: 2780583-7-TEST_ONLY.patch, failed testing.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

The fix looks perfect for me!

  1. +++ b/core/modules/views_ui/src/Tests/TokenizeAreaUITest.php
    @@ -0,0 +1,46 @@
    +
    +  /**
    +   * {@inheritdoc}
    +   */
    +  public static $modules = ['entity_test'];
    

    I like that we don't use node but rather the test entity type.

  2. +++ b/core/modules/views_ui/src/Tests/TokenizeAreaUITest.php
    @@ -0,0 +1,46 @@
    +    $default = $this->randomView([]);
    +    $id = $default['id'];
    +    $view = View::load($id);
    

    Its kinda funny how bad this API is :)

  • catch committed bd1b3a4 on 8.3.x
    Issue #2780583 by Lendude, joachim, Nitebreed: Views field token...

  • catch committed c9acfac on 8.2.x
    Issue #2780583 by Lendude, joachim, Nitebreed: Views field token...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.3.x and cherry-picked to 8.2.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.