Thursday, December 8, 2016

Drupal 8 (twig): If node id equals x, do something (example)

How to create an if conditional statement based on node id?

For Drupal 8, you use the variable "node.id" (using Twig)

 {% if node.id == 206 %}class="active"{% endif %} 

Basically this means, add the class "active" if current node id is "206".

No comments:

Post a Comment