Skip to content
● Meet Grav Guard: keep every Grav site you run secure and up to date, all from one place. Free for up to 3 sites. Read more →

Can I filter a page collection by available language translations?

Solved by Ron Wardenier View solution

Started by Peter Rankin 9 years ago · 2 replies · 1210 views
9 years ago

On the documentation, I see there are lots of ways of filtering/sorting pages in a collection (taxonomy, date, etc.). Can I add a filter for available language translations?

For instance, I would like to show only a list of pages with an available translation in Spanish. Is that possible using collections? Thanks!

9 years ago Solution

A similar questions has been asked before. The answer was using the translatedLanguages method of the Page object.
When I search the web for "grav translatedLanguages" I see a couple of use cases. That must get you going again. I hope.

9 years ago

Thanks, that got me going! I might try to see if I can code a pull request so a sort of "no language fallback" feature for page collections can be included in those defined in frontmatter, to avoid the need for Twig/PHP for this filter.

Thanks again!

Suggested topics

Topic Participants Replies Views Activity
General · by Hanns Mattes, 6 days ago
0 93 6 days ago
General · by Dima, 2 weeks ago
1 121 2 weeks ago
General · by pamtbaau, 2 weeks ago
0 194 2 weeks ago
General · by lynbor, 2 months ago
5 701 4 weeks ago
General · by Andy Miller, 1 month ago
0 427 1 month ago