Hi,

i try to print in D8beta4 {{ field_youtube-input }} and {{ field_youtube-video_id }} in a field based content view.
This prints in both cases "0" instead of the values.

Can someone reproduce this?

Thanks and regards

Comments

sachbearbeiter’s picture

Or do i have to create an extra "ID" formatter for the module?

guschilds’s picture

Status: Active » Postponed

sachbearbeiter,

I am able to reproduce this with both a YouTube field and core fields.

Steps to reproduce:

1. Add fields to test (YouTube, Image, Link, Reference, etc) a content type.
2. Create content of that type with values in those fields.
3. Create a view that displays fields and lists that type of content
4. Add the fields to test to the display.
5. In each field's configuration, enable "Rewrite Results > Override the output of this field with custom text"
6. Find replacement patterns for that field that contain a hyphen ("-").
7. Place that replacement pattern in the Text field. Click "Apply".

Expected result: the token is replaced with the expected value. Ex: "{{ field_video-video_id }}" is replaced with "r0wt-5lCdb4" within the view display when that field's value was originally "https://www.youtube.com/watch?v=r0wt-5lCdb4".

Actual result: the token is always replaced with "0".

As mentioned, I've confirmed this with YouTube fields and core fields, including:

  • Image ({{ field_image-target_id }}, {{ field_image-alt }}, {{ field_image-title }}, {{ field_image-width }}, and {{ field_image-height }})
  • Link ({{ field_link-uri }}, {{ field_link-title }}, and {{ field_link-options }})
  • Entity Reference ({{ field_reference-target_id }})

Because I get "0" for all core tokens as well, this is likely either a bug with core or there is something else involved that I/we are not aware of. I don't see any mention of it at a glance in the original issue, #2342287: Allow Twig in Views token replacement. Please create an issue against core if you'd like.

I'm going to set this as postponed until core field replacements work. We will try again then and if YouTube field replacements work, this can be closed. Otherwise it will need to be fixed.

Thanks!

guschilds’s picture

I have tested this again and it is still a problem with both YouTube and core fields. I was able to find #2371633: Views uses hyphens in many tokens, but that is not valid Twig syntax., which addresses the exact problem. I tested the patch in #20 and was getting correct rewriting for {{ field_video__input }} and {{ field_video__video_id }} (notice the double underscore instead of hyphen now). I'll leave this issue open until that (or a similar) fix is committed to core. Once it is, I'll test again and close this if it works properly without patching core.

guschilds’s picture

Status: Postponed » Closed (works as designed)

As of the commit in #49 of #2546210: Views subtokens are broken since the introduction of inline templates for replacements, this is no longer a problem. Replacement tokens work as expected when re-writing Views output.