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

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Support

If a Taxonomy Exists

Solved by Paul Hibbitts View solution

Started by Claud Rusnac 8 years ago · 1 replies · 523 views
8 years ago

I am trying to write some code to determine if a Taxonomy is set on a particular page, but I must be doing something wrong...

TWIG
{% if page.taxonomy.type == "general" %}
            Do Something... 
{% endif %}

Page Header

YAML
---
title: Page Title
taxonomy:
    category: ['docs']
    role:
    type: ['general']
    execution:
modified_date: 10/12/2017
---
8 years ago Solution

Hi @crusnac, this is untested but perhaps this?

TWIG
{% if "general" in page.taxonomy['type'] %} 

Let me know if that actually works🙂

👍 1

Suggested topics

Topic Participants Replies Views Activity
Support · by Thomas, 1 week ago
2 60 16 hours ago
Support · by Anna, 3 days ago
2 66 19 hours ago
Support · by Justin Young, 20 hours ago
1 34 20 hours ago
Support · by Duc , 1 week ago
2 70 6 days ago
Support · by Colin Hume, 1 week ago
2 61 6 days ago