Complex Collections

I want to create a collection of all pages from a given directory but with an additional criterion which is a specific value in the taxonomy.

I followed the example of Complex Collections from the documentation but I have a problem with it.

I have this structure:
/services/brakes/offer.md

Contents of the offer.md file:

---
title: Brakes
taxonomy:
   branch: ['Las Vegas', 'Montreal']
---

I also have:
/branches/new-york/section.md

Contents of the section.md file:

---
title: New York
content:
    items:
      - '@page.children': '/services'
      - '@taxonomy':
            branch: ['New York']
---

And it shows me Brakes…

@q3d,

According the first paragraph of the docs on Complex Collections:

[…] the resulting collection will be the sum of all the pages found from each of the collection definitions.

Since /services/brakes/offer.md is a child of /services it will be included in the result.

:blush:

Is there a way to define a collection so that it does not contain pages with e.g. a specific value in the taxonomy?

@q3d, It depends on what you are trying to achieve…

Please show:

  • A part of your folder structure that is involved in the collection.
  • Show filenames and relevant assigned categories per file
  • Which pages you would like to be added to the collection.

Thank you for your help.

The structure is as in the first post. I have a service directory. In the service directory, a directory for each service with a .md file. In the .md file in the taxonomy section, I have entered the branches where the service is available.

On the branch page (modular) in the services section, I want to display only the services available in this branch.

@q3d,

---
title: New York
content:
    items:
      '@taxonomy.branch':  'New York'
---

But I also wanted to use this taxonomy in other places, e.g. to mark customer reviews.

/testimonials/john-doe/testimonial.md

testimonial.md:

taxonomy:
   branch: 'New York'

What you propose will get all pages from both the services directory and the testimonials directory.

I think I need to rest for a while :slight_smile:

@q3d,

I asked for a detailed description of your situation for a reason… For clarity and preciseness.

You stated your goal as:

On the branch page (modular) in the services section, I want to display only the services available in this branch.

My answer applies to that description.

But I also wanted to use this taxonomy in other places, e.g. to mark customer reviews.

Now you are changing the situation. You’re adding an extra folder in which the branch taxonomy is also being used and you are changing the goal…

I think I need to rest for a while

No no, just read the docs on Complex Collections again.

---
title: New York
content:
  items:
    '@taxonomy.branch':  'New York'
  filter:
    type: offer
---

Of course, you are right. Thx.

I did it yesterday like this:

---
title: New York
content:
  items:
    '@taxonomy.category': 'offer'
    '@taxonomy.branch': 'New York'
---

It seems to work fine in my case too.

@q3d, You are already differentiating pages using different templates. Adding an extra category tag to differentiate seem like an overhead…

Although the template’s blueprint can set the category automatically, it still seems unnecessary…

As usual, you’re right. That’s why at first I didn’t want to add an extra tag and was looking for another solution. Because I didn’t understand that type: 'blog' means template page.

The solution you provided is perfect in my case:

---
title: New York
content:
  items:
    '@taxonomy.branch':  'New York'
  filter:
    type: offer
---

Thx!