Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

IF is not or is not - how it twig?

Started by Muut Archive 10 years ago · 5 replies · 859 views
10 years ago

So I want to display email newsletter box that will be displayed in footer unless the page template is home or domains. I am struggling to come up with correct syntax for it, this one does not work:

{% if (page.template != 'home') or (page.template != 'domains') %}

Any suggestions what is correct way to write it?

10 years ago

perhaps:
{% if not ( page.template == 'home' ) or not ( page.template == 'domains' ) %}
doc twig

10 years ago

This works:

TWIG
{% if page.template != "home" or "domains" %}
    Not Home or Domains
{% else %}
    Home or Domains
{% endif %}
10 years ago

@kyodev does not work

@OleVik your example will apply the condition for home page but it won't apply for domains

10 years ago

@OleVik correction - yours does not work as well

10 years ago

I ended up doing something like this:

TWIG
{% if page.template != 'home' %}
  {% if page.template != 'domains' %}

    ### display something when the page is not home or domains

  {% else %}
  {% endif %}
{% else %}
{% endif %}

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1356 9 years ago
Archive · by Muut Archive, 9 years ago
2 936 9 years ago
Archive · by Muut Archive, 9 years ago
2 4066 9 years ago
Archive · by Muut Archive, 9 years ago
1 2954 9 years ago
Archive · by Muut Archive, 9 years ago
3 1120 9 years ago