hello all! i’m trying to create a filter on a CMS data loader component that filters the CMS entries displayed based on a select field that is also on the page. the select field is used to pick a US state for which a given CMS entry is for. CMS entries could be available in one or multiple locations. any suggestions on the best way to accomplish this? the Filter field
options don’t appear to support the list
field type
Unfortunately I don’t think we currently support server side filtering over collections, but you would be able to perform this filtering client-side (using dynamic values and JS code that .filter’s over the array) - would that work for you?
Yea that would!
It would work something like this:
• Set noAutoRepeat
prop on the CMS data fetcher component
• Inside the component’s slot, make an element repeat by an expression like this (variable names need to change based on your actual models / fields / select elements):
$ctx.plasmicCmsItemsCollection.filter(item => item.availableStates.some(state => state.name === $state.select1.value)))
hey yang thanks for this, not exactly sure which child to put this on. in the child slot for the CMS data fetcher right now i have a single vertical stack with 4 items in the stack — all CMS Entry Values
You can apply the Repeat to the element where you want one copy per item in the fetched result
For instance, let’s say your CMS data fetcher gets a list of 10 items, and say you want the whole vertical stack of 4 CMS Entry Values to be repeated once per each of the 10 items, then you would set the Repeat on the vertical stack