Friday, 15 February 2013

php - Applying twig filters in Drupal 8 Views Template -


I am using a theme view in Drupal 8 that uses the trigger. I would like to use the Tribune filter on the row.content variable in the View-View-unformatted.html.twig template.

It seems that row.content is an array, so the string of the twig does not manipulate the job. However, it prints on the page as a string (see only the list of classification conditions).

What I want to do is to mess out the output, so the classification words with spaces may contain valid href, change the filter in the code below.

  & lt; Ul class = "nav nav-tabs" role = "tablist" & gt; For {% rows in rows%} & lt; Li role = "presentation" class = "{{loop.first? 'Active': ''}}" & gt; "{{Row.content}}" role = "tab" data-toggle = "tab" & gt; {{Row.content}} & lt; / A & gt; & Lt; / Li & gt; {% Endfor%} & lt; / Ul & gt;  

This only outputs and . Does anyone know how to use Raw text value of production during Tweezes interpolation?

Thank you!

I ran into it on myself because it was difficult because the crashes on beams and dump scenes. Although there is a quick solution to get bits, enter it under the {% in rows in rows} in your trigger view style template.

  & lt; Ol & gt; Key for {%, line in concert%} 
  • gt; {{Key}} & lt; / Li & gt; {% Endfor%} & lt; / Ol & gt;
  • Load with that page & amp; You get a key to see, I checked each with the following dump command, just added below the test.

    The above dump showed all the stuff in #ro, where I Dug and got the field that I wanted (can be different for you), then I wanted to replace the empty space with the dash. Lowercase the lowercase

    Everything past row.content ['# Line'] is probably different for you, you have to dig into a small array with the order of the above given dump. The below is the line I got.

      {{row.content ['# row'] ._ entity.title [0] .value | Replace ('', '-') | Less}}  

    Below is an example of a toggle template. Change the file name change to the name of the view and block-3 in your setup.

    View-view-unchanged - View-name - Block-3 Html.twig

    {% line in line%} {% set} Row_classes = [default_row_class? '{{Row.content [' # row '].' Entity quote '[0] ; & Lt; Section {{row.attributes.addClass (row_classes)}} id = "{{row.content ['# row'] ._ entity.title [0] .value | replace ('', '-') | less} } "& Gt; {{Row.content}} & lt; / Section & gt; {% Endfor%}

    I'm sure there are so many other ways to do this, but it works as a quick solution for me to print the visual field in the style template. That's really useful.


    No comments:

    Post a Comment