Linked Questions

1 vote
1 answer
469 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 ...
0 votes
1 answer
47 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....
0 votes
1 answer
42 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 ...
  • 173
0 votes
1 answer
300 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>...
0 votes
1 answer
1k 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&...
0 votes
1 answer
135 views

Get raw value of a block content

I have created several views. These views have a block display. If I use these blocks in my template, the views are rendered with all the wrappers / divs. In my block template, can I alter the output ...
  • 109
0 votes
1 answer
528 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|...
0 votes
1 answer
1k views

Call preprocess_node (or get variables) from Twig template?

I have the following content types (for a simple LMS) defined: Lessons, for which there are rather complex rules for handling view access. Courses, which contain entity references to one or more ...
  • 269
0 votes
1 answer
131 views

What's the best way to put in a link to a translated node in a D8 template? [closed]

There just has to be a better way to insert a link to an alternative translation than this: function THEME_preprocess_node(&$variables) { $node = &$variables['node']; // Current ...
0 votes
1 answer
3k views

How do I calculate field_1 + field_2 in Twig?

I have two fields. {{ content.field_1 }} is 2; {{ content.field_2 }} is 5. How do I multiply them to obtain 10, in a template file?
-1 votes
1 answer
2k 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" {% ...
  • 145
-1 votes
1 answer
73 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 ...
  • 1,027
-4 votes
1 answer
42 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
18 views

How to strip tags/ or just trim content but preserve ampersand in field content [duplicate]

The issue : striptags removes "&" from the fields content as well. {{ label }} preservers the "&" but I am not able to trim the content. I have twig_extender enabled <...
  • 1
0 votes
0 answers
122 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....

15 30 50 per page