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

If a Taxonomy Exists

Solved by Paul Hibbitts View solution

Started by Claud Rusnac 8 years ago · 1 replies · 621 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 Anna, 18 hours ago
1 54 11 hours ago
Support · by gtx, 1 week ago
4 228 2 days ago
Support · by Paul Hodges, 2 weeks ago
13 277 5 days ago
Support · by Anna, 3 weeks ago
9 335 1 week ago
Support · by TomW, 2 weeks ago
4 188 2 weeks ago