Skip to content
● Meet Grav Guard: keep every Grav site you run secure and up to date, all from one place. Free for up to 3 sites. Read more →

If a Taxonomy Exists

Solved by Paul Hibbitts View solution

Started by Claud Rusnac 9 years ago · 1 replies · 834 views
9 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
---
9 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 TomW, 2 weeks ago
8 227 9 hours ago
Support · by alex, 2 months ago
8 667 23 hours ago
Support · by Supple, 5 days ago
1 98 1 day ago
Support · by TomW, 1 week ago
3 159 3 days ago
Support · by TomW, 6 days ago
2 106 5 days ago