Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

filter or querying list based on locale

default discord avatar
rrums2 years ago
1

hi all!



i.e. set localization to ['gb', 'us', 'au']


there is a "Page" collection with locale (select) field with same options as localization



is it possible to filter list based on locale?


i want to render (or apply filter automatically) the list only with certain locale that chosen



is there a way to do this in payload?


thank you



just found that we can retrieve current locale from req, so the solution is something like this in collection access control



access: {
        // @ts-ignore
        read: ({req: {locale}}) => {
            return {
                locale: {
                    equals: locale
                }
            }
        }
    },
    Star on GitHub

    Star

    Chat on Discord

    Discord

    online

    Can't find what you're looking for?

    Get dedicated engineering support directly from the Payload team.