We are trying to setup a content directory within our site, that can be used to populate subdirectories on the same install. Based on docs, Taxonomy is the way to do it.
So for example, I have a twig template that takes a header variable and uses it in a custom search for taxonomy:
{% set source = page.header.source %}
{% for post in taxonomy.findTaxonomy({
'category': 'blue',
'name': source,
'page': 'purple'
}) %}
{{ post.content }}
{% endfor %}
Assuming that between the three taxonomies (which are all defined in site.yaml) there is only one content page matching (I've confirmed this by using these dummy category and page values on only one page, the documentation leads me to believe that the returned array will have that one page.
However, in my testing, {{ post.content }} spits out the content for all pages that match one of the categories, which means that I actually have to do filtering in the loop? This was my solution, but it requires values to be unique else the variables are just overwritten with the last matching value:
{% set details = [] %}
{% set feature = [] %}
{% set source = page.header.source %}
{% for subpage in taxonomy.findTaxonomy({
'category': 'details',
'name': source,
'page': 'feature'
}) %}
{% if "details" in subpage.taxonomy.category %}
{% set details = subpage %}
{% endif %}
{% if "marketing" in subpage.taxonomy.category %}
{% set feature = subpage %}
{% endif %}
{% endfor %}
Am I misunderstanding findTaxonomy or is this a bug with the functionality, or something else?
Thanks in advance for help!