Skip to main content
Post Closed as "Duplicate" by Alfred Armstrong, DRUPWAY, leymannx, sanzante, Yuseferi
added 13 characters in body; edited title
Source Link
leymannx
  • 18.8k
  • 6
  • 72
  • 126

How to get value from {{ item.content [drupal 8]?}}

I have a node named "reviews" and a custom field named "field_rating". I created a field template named "field--node--field_rating--reviews.htmlfield--node--field_rating--reviews.html.twig.twig" I

I want inside the node to change the color with an if statement. I

I try to do something like that:

{% for item in items %}
  {% if item.content > 5 %}
    <div style="background-color:green">{{ item.content }}</div>
  {% endif %}
{% endfor %}

but it doesn't work.

Any suggestions?

Drupal Version 8.6.1

How to get value from item.content [drupal 8]?

I have a node named "reviews" and a custom field named "field_rating". I created a field template named "field--node--field_rating--reviews.html.twig" I want inside the node to change the color with an if statement. I try to do something like that:

{% for item in items %}
{% if item.content > 5 %}
<div style="background-color:green">{{ item.content }}</div>
{% endif %}
{% endfor %}

but it doesn't work.

Any suggestions?

Drupal Version 8.6.1

How to get value from {{ item.content }}

I have a node named "reviews" and a custom field named "field_rating". I created a field template named field--node--field_rating--reviews.html.twig.

I want inside the node to change the color with an if statement.

I try to do something like that:

{% for item in items %}
  {% if item.content > 5 %}
    <div style="background-color:green">{{ item.content }}</div>
  {% endif %}
{% endfor %}

but it doesn't work.

Any suggestions?

Drupal Version 8.6.1

edited tags
Source Link

I have a node named "reviews" and a custom field named "field_rating". I created a field template named "field--node--field_rating--reviews.html.twig" I want inside the node to change the color with an if statement. I try to do something like that:

{% for item in items %}
{% if item.content > 5 %}
<div style="background-color:green">{{ item.content }}</div>
{% endif %}
{% endfor %}

but it doesn't work.

Any suggestions?

Drupal Version 8.6.1

I have a node named "reviews" and a custom field named "field_rating". I created a field template named "field--node--field_rating--reviews.html.twig" I want inside the node to change the color with an if statement. I try to do something like that:

{% for item in items %}
{% if item.content > 5 %}
<div style="background-color:green">{{ item.content}}</div>
{% endif %}
{% endfor %}

but it doesn't work.

Any suggestions?

Drupal Version 8.6.1

I have a node named "reviews" and a custom field named "field_rating". I created a field template named "field--node--field_rating--reviews.html.twig" I want inside the node to change the color with an if statement. I try to do something like that:

{% for item in items %}
{% if item.content > 5 %}
<div style="background-color:green">{{ item.content }}</div>
{% endif %}
{% endfor %}

but it doesn't work.

Any suggestions?

Drupal Version 8.6.1

added 1 character in body
Source Link

I have a node named "reviews" and a custom field named "field_rating". I created a field template named "field--node--field_rating--reviews.html.twig" I want inside the node to change the color with an if statement. I try to do something like that:

{% for item in items %}
{% if item.content > 5 %}
<div style="background-color:green">{{ item.content}}</div>
{% endif %}
{% endfor %}

but it doesn't work.

Any suggestionsuggestions?

Drupal Version 8.6.1

I have a node named "reviews" and a custom field named "field_rating". I created a field template named "field--node--field_rating--reviews.html.twig" I want inside the node to change the color with an if statement. I try to do something like that:

{% for item in items %}
{% if item.content > 5 %}
<div style="background-color:green">{{ item.content}}</div>
{% endif %}
{% endfor %}

but it doesn't work.

Any suggestion?

Drupal Version 8.6.1

I have a node named "reviews" and a custom field named "field_rating". I created a field template named "field--node--field_rating--reviews.html.twig" I want inside the node to change the color with an if statement. I try to do something like that:

{% for item in items %}
{% if item.content > 5 %}
<div style="background-color:green">{{ item.content}}</div>
{% endif %}
{% endfor %}

but it doesn't work.

Any suggestions?

Drupal Version 8.6.1

Source Link
Loading