Skip to main content
added 69 characters in body
Source Link
Prestosaurus
  • 2.1k
  • 1
  • 14
  • 29

Not sure about page.html.twig. Would have to dig around...

In node.html.twig:

{%
  set newClassNameVar = "standard" %}
[
{% if   node.type.entity.label == "program" %}
    {%'Program' set? newClassNameVar'Program' =: "program"'Not %}Program'
{% endif ]
%}

<div class="{{ attributes.addClass(newClassNameVar) }}"><></div>

Oror:

{%
  set newClassNameVar = [
    node.type.entity.labelbundle == 'Program''content__type' ? 'Program''set-yes-class' : 'Not Program''set-no-class'
  ]
%}

<div{{ attributes.addClass(newClassNameVar) }}></div>

use debug such as {{ dump(_context | keys) }} to see what is available and best suits your use case.

Not sure about page.html.twig. Would have to dig around...

In node.html.twig:

{% set newClassNameVar = "standard" %}

{% if node.type.entity.label == "program" %}
    {% set newClassNameVar = "program" %}
{% endif %}

<div class="{{ newClassNameVar }}"></div>

Or:

{%
  set newClassNameVar = [
    node.type.entity.label == 'Program' ? 'Program' : 'Not Program'
  ]
%}

<div{{ attributes.addClass(newClassNameVar) }}></div>

Not sure about page.html.twig. Would have to dig around...

In node.html.twig:

{%
  set newClassNameVar = [
    node.type.entity.label == 'Program' ? 'Program' : 'Not Program'
  ]
%}

<div{{ attributes.addClass(newClassNameVar) }}></div>

or:

{%
  set newClassNameVar = [
    node.bundle == 'content__type' ? 'set-yes-class' : 'set-no-class'
  ]
%}

<div{{ attributes.addClass(newClassNameVar) }}></div>

use debug such as {{ dump(_context | keys) }} to see what is available and best suits your use case.

deleted 9 characters in body
Source Link
Prestosaurus
  • 2.1k
  • 1
  • 14
  • 29

Not sure about page.html.twig. Would have to dig around...

In node.html.twig:

{% set newClassNameVar = "standard" %}

{% if node.type.entity.label == "program" %}
    {% set newClassNameVar = "program" %}
{% endif %}

then:

 
<div class="{{ newClassNameVar }}"></div>

Or:

{%
  set newClassNameVar = [
    node.type.entity.label == 'Program' ? 'Program' : 'Not Program'
  ]
%}

<div{{ attributes.addClass(newClassNameVar) }}></div>

Not sure about page.html.twig. Would have to dig around...

In node.html.twig:

{% set newClassNameVar = "standard" %}

{% if node.type.entity.label == "program" %}
    {% set newClassNameVar = "program" %}
{% endif %}

then:

<div class="{{ newClassNameVar }}"></div>

Or:

{%
  set newClassNameVar = [
    node.type.entity.label == 'Program' ? 'Program' : 'Not Program'
  ]
%}

<div{{ attributes.addClass(newClassNameVar) }}></div>

Not sure about page.html.twig. Would have to dig around...

In node.html.twig:

{% set newClassNameVar = "standard" %}

{% if node.type.entity.label == "program" %}
    {% set newClassNameVar = "program" %}
{% endif %}
 
<div class="{{ newClassNameVar }}"></div>

Or:

{%
  set newClassNameVar = [
    node.type.entity.label == 'Program' ? 'Program' : 'Not Program'
  ]
%}

<div{{ attributes.addClass(newClassNameVar) }}></div>
added 199 characters in body
Source Link
Prestosaurus
  • 2.1k
  • 1
  • 14
  • 29

Not sure about page.html.twig. Would have to dig around...

In node.html.twig:

{% set newClassNameVar = "standard" %}

{% if node.type.entity.label == "program" %}
    {% set newClassNameVar = "program" %}
{% endif %}

then:

<div class="{{ newClassNameVar }}"></div>

Or:

{%
  set newClassNameVar = [
    node.type.entity.label == 'Program' ? 'Program' : 'Not Program'
  ]
%}

<div{{ attributes.addClass(newClassNameVar) }}></div>

Not sure about page.html.twig. Would have to dig around...

In node.html.twig:

{% set newClassNameVar = "standard" %}

{% if node.type.entity.label == "program" %}
    {% set newClassNameVar = "program" %}
{% endif %}

then:

<div class="{{ newClassNameVar }}"></div>

Not sure about page.html.twig. Would have to dig around...

In node.html.twig:

{% set newClassNameVar = "standard" %}

{% if node.type.entity.label == "program" %}
    {% set newClassNameVar = "program" %}
{% endif %}

then:

<div class="{{ newClassNameVar }}"></div>

Or:

{%
  set newClassNameVar = [
    node.type.entity.label == 'Program' ? 'Program' : 'Not Program'
  ]
%}

<div{{ attributes.addClass(newClassNameVar) }}></div>
Source Link
Prestosaurus
  • 2.1k
  • 1
  • 14
  • 29
Loading