grav icon indicating copy to clipboard operation
grav copied to clipboard

[FeatureRequest] Twig: Filter a Collection by notOfType

Open kittyfishfrommars opened this issue 9 months ago • 1 comments

Currently Grav supports filtering a Page Collection by including specific templates types via Collection::ofType.

I would also like to exclude specific template types from a Page Collection, so I can display the results differently.

This could be achieved via Collection::notOfType. Preferably this new function accepts an Array or List for to remove multiple templates at once.

Acceptance Criteria

  • In Twig It is possible to exclude a single/multiple template types from a Page Collection

Solution

  • page.collection()|filter(module => module.template != 'modular/links') where modular/links is the template to exclude

kittyfishfrommars avatar Mar 05 '25 21:03 kittyfishfrommars

How about a PR? Seems you have a need, have a solution, just create a PR for this feature, and it could get merged.

rhukster avatar Jun 13 '25 15:06 rhukster