This one always gets me.
I have a collecction of
I also have a collection of
portfolio.yml pages that have a pages field, where
work pages can be selected:
Now I want to make a collection of all
work pages that are NOT selected in ANY of the
portfolio pages works field.
I can nest loops and the like, but… is there any smart way to pull this, kirby-way ?
This should work (at least it used to work with page ids not sure about uuids:
$selectedWorks = page('portfolio')->children()->pluck('works', '-', true);
$unselectedworks = page('portfolio')->children()->not($selectedWorks);
Ok, important to note that work.yml are not children of portfolio.yml but actually siblings.
But $portfolioPage->works() is a pages field that contains a selection of work pages.
what does pluck do there ?
Well, but the logic remains the same, then adapt as required.
It fetches all entries of the works field of the given collection into an array