Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
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
Comment #1
sachbearbeiter CreditAttribution: sachbearbeiter commentedOr do i have to create an extra "ID" formatter for the module?
Comment #2
guschilds CreditAttribution: guschilds commentedsachbearbeiter,
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:
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!
Comment #3
guschilds CreditAttribution: guschilds at Chromatic commentedI 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.Comment #4
guschilds CreditAttribution: guschilds at Chromatic commentedAs 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.