Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I have a path field in a view which I have hidden and I want to access the link in my custom views-view-fields--[views-name]--[display-type].html.twig
For this I use:
<a href="{{ fields.path.content|render|striptags|trim }}">
The problem is that the link is only inserted if the path field is not hidden. Otherwise the output of the variable is empty.
Comments
Comment #2
johnnny83 CreditAttribution: johnnny83 commentedComment #9
LendudeGoing through old issues for the Bug Smash Initiative.
I'd say this is by design, the field is hidden, which in Views lingo means it shouldn't be rendered, so it's not passed on to the rendering layer.
If you feel that this is something that is needed we could reopen this as a feature request, but not sure this would fit the 80% case.
Comment #10
johnnny83 CreditAttribution: johnnny83 commentedUh, this is six years ago and I absolutely don't remember why I needed this 😅, but I suppose I managed to solve it some other way. But thank you for asking!
Anyway, a hidden field can be embedded in other fields or used for grouping etc. so it is still available for other actions, so I think then it should also be accessible in twig.