Skip to content
● Grav 2.2 is out: 2x faster cold starts and 96% less memory on big sites. Read the announcement →

If a Taxonomy Exists

Solved by Paul Hibbitts View solution

Started by Claud Rusnac 9 years ago · 1 replies · 732 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 webmasterodp, 7 days ago
4 145 6 days ago
Support · by nwhitfield, 1 week ago
2 125 1 week ago
Support · by stell, 3 weeks ago
5 364 2 weeks ago
Support · by gravinator, 1 month ago
5 555 2 weeks ago
Support · by Gravver, 3 weeks ago
6 344 3 weeks ago