0

I'm creating a view that shows a list of "articles" with a contextual filter, "organization", to be shown as a block in the organization detail page. I configured the filter so that it grabs the organization ID from the URL (URL being something like node/123). I want the block to show 3 articles, and a "more" link that points to a page I'll build in the future. For now, I want this URL to point to the organization page (i.e. to the same page, bear with me with this part).

Now, configuring the "more" link in the view, I selected Custom URL on the Link display setting. The modal box says this:

The following tokens are available for this link. You may use Twig syntax in this field.

  • {{ arguments.field_organization_target_id }} == Content: Organization (field_organization) title
  • {{ raw_arguments.field_organization_target_id }} == Content: Organization (field_organization) input

Now, I assume I can use these tokens to build my URL. I tried both of them in the Custom URL text field, like so:

/node/{{ raw_arguments.field_organization_target_id }}

But when trying to open the page, it shows a massive error:

The website encountered an unexpected error. Please try again later.

AssertionError: Tokens need to be valid Twig variables. in Drupal\Component\Assertion\Handle::Drupal\Component\Assertion\{closure}() (line 373 of core/modules/views/src/Plugin/views/PluginBase.php).
assert('preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $token) === 1', 'Tokens need to be valid Twig variables.')
Drupal\views\Plugin\views\PluginBase->viewsTokenReplace('/node/{{ raw_arguments.field_organization_target_id }}', Array)
Drupal\views\Plugin\views\display\DisplayPluginBase->renderMoreLink()
...

The error goes on, but I think this first part shows what's relevant: this is related to Twig and the renderMoreLink method.

I also tried a simple URL like /node/2, but I get the same error (same thing without the first slash character). How can I make this work?

  • Were you able to get this working? – Gokul N K May 19 '16 at 8:30
  • @GokulNK no, I still see this error (just upgraded to 8.1.5). – cambraca Jul 8 '16 at 2:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.