0
votes

I am new to drupal 8. I want something like this:

{% if node.2 %}
...............
.........
{% endif %}    

what is the correct code for this? In back end I have created several nodes like node/1, node/2. I want to put a condition in node.html.twig.

how can I achieve this?

2
What is node? How did you pass it towards the view? - DarkBee

2 Answers

0
votes

Got to twig documentation:

{% if node is not empty %}
   {% for oneNode as node %}
      {{ oneNode.title }}
      {{ oneNode.body }}
      ..................
   {% endfor %}
{% endif %}
0
votes

Try Like this way....

{% if node.id == 2 %}
  YOUR CODE..............
{% endif %}