Linked Questions
29 questions linked to/from How do I get the raw field value in a twig template?
1
vote
1
answer
213
views
Why precisely the twig raw filter is unsecure?
Why precisely the twig raw filter is insecure in the drupal context?
What would be an example of a potential threat ?
And what need to be done on the ckeditor field format side to protect potential ...
0
votes
1
answer
641
views
|slice filter does not work with special characters
I try to use the slice filter in order to limit a link to a specific amount of characters. The field that I render is a link field and my code is the following:
{% set title_text = title|render|...
6
votes
8
answers
39k
views
How do I convert special characters into html in twig
I have some list items in drupal 8 which created by item_list template.I am sending some <a> tagged data to the item_list template. My idea was to get the output as <a href="/this-is-new.html"...
0
votes
1
answer
100
views
Applying trim to paragraph value
I have the following Paragraph template which displays a heading with a trailing orange dot. The field itself is a normal text field in Drupal. For some reason, there is a trailing space after the ...
0
votes
1
answer
188
views
Twig Template - Div Element Being Inserted in Link URL [duplicate]
I have a link field type that I'm referencing in a Twig template. I'm using this code:
<div class="outlined">
<a href="{{content.field_3_column_image_link}}">{{content....
1
vote
1
answer
1k
views
Check if a field is empty inside a twig paragraph template
I know how to check if a field is empty in a twig template (example node--lorem.html.twig):
{% if node.field_lorem.value is not empty %}
<p>not empty</p>
{% else %}
<p>...
3
votes
1
answer
2k
views
How to add condition for 1st Iteration in views-view-fields.html.twig file
I am trying to implement a carousel , inside my views-view-fields--block_1.html.twig , I want to add active class inside the div for the first Iteration . I have added the code in twig file but every ...
0
votes
1
answer
6k
views
How to get field value from paragraph entity in twig?
Is it possible to get the value from the field inside the paragraph in the red rectangle.
This code part is placed within a twig-template "field--block-content--field-example.html.twig"
{% ...
-1
votes
1
answer
111
views
How to use a Twig variable as View name in drupal_view() Twig Tweaks function? [duplicate]
This works:
{{ drupal_view('nursing_resource_blog_teasers', 'block_1') }
But this doesn't:
{% set view_name = "nursing_resource_blog_teasers" %}
{{ drupal_view(view_name , 'block_1') }
It ...
0
votes
1
answer
2k
views
Twig escapes tags when using raw value in template
I am printing fields in a node template, but Twig is escaping my tags and ruining my day.
My .tpl looks like this:
<blockquote>
<p class="title">{{ content.field_myfield.0 }}</p&...
1
vote
1
answer
468
views
How can I embed a view in a template when passing view name and parameters are passed as variables?
Inside my paragraph template I have variables which contain category id and view machine name. So when I print them like this:
{{ content.field_category }}
{{ content.field_view }}
I get correct ...
-4
votes
1
answer
43
views
How can you separately get the name and the value of a field?
I want to get the key and the value of my row for example I have this:
{{ content.field_nom }}
but the out put is:
my field name
my value
My question is how do you get 'my field name' alone ...
0
votes
0
answers
123
views
how to get values for my content type drupal 8
i have a problem to get values in my twig for my content type , i have just the '{{content}}' variable with a lot of arrays , how can i get for example my field 'field_image' ?
<div{{ attributes....
1
vote
1
answer
721
views
how do I access raw URL from a File Field to render it in twig inside href? [duplicate]
I have a "Our Staff" Content Type, that includes a field for uploading an individual's CV as a PDF:
field_cv_file
I have created a View for this Content Type, then added it to page via Blocks
The ...
1
vote
3
answers
795
views
Body Summary field showing literal ampersand character code in view
I have a Drupal 8 site where we've created a view, and decided to use the summary field instead of the trimmed body field, so that we could have more control over it.
However, I got a bug report ...