Complex collection filter : taxonomy for page children

Hi !

I have two pages where I post items : blog (for normal blog posts) and files (for files like pdfs). Those two pages share a common taxonomy : I use tags to determine to which project a blog post or a file belongs (can be several projects at once).

Now I’d like to display two different lists on my project page : recent posts and recent files. I’d like to show only posts/files for that specific project. I thought it would be easy using Grav, but I’m stuck.

This doesn’t work, as it seems the returned collection is an union of @page and @taxonomy instead of an intersection :

{% set projects_last_posts = page.collection({'items':{'@page.children':'/blog', '@taxonomy.tag':'my_project'}}) %}
{% set projects_last_files = page.collection({'items':{'@page.children':'/files', '@taxonomy.tag':'my_project'}}) %}

It seems like a relatively simple use case, but reading the doc, I don’t see how I can achieve this.

Help would be greatly appreciated !



Hi Olivier,
Maybe you could try it with taxonomy.findTaxonomy()
You would have to use a second taxonomy like “category” to make it work correctly, though…
So, on all your files you could set "category:file" and "tag:my_project" and on the posts "category:post" and "tag:my_project"

Then on your project page:

{% set projects_last_posts = taxonomy.findTaxonomy({'category':'post','tag':'my_project'}) %}
{% set projects_last_files = taxonomy.findTaxonomy({'category':'file','tag':'my_project'}) %}

Maybe this works for your use case?