Is it possible to access custom fields in a where statement?
For instance, I have a custom selectbox field on my images, and I want to be able to filter the images based on the custom field selection.
Here is my custom field for reference:
{
"category":{
"label":"Category",
"type":"select",
"options":[{
"value":"",
"label":"None"
},{
"value":"kitchen-dining",
"label":"Kitchen / Dining"
},{
"value":"bathroom-bedroom",
"label":"Bathroom / Bedroom"
},{
"value":"living-areas",
"label":"Living Areas"
},{
"value":"condominiums",
"label":"Condominiums"
},{
"value":"mudrooms",
"label":"Mudrooms"
},{
"value":"details",
"label":"Details"
},{
"value":"custom-homes",
"label":"Custom Homes"
},{
"value":"commercial",
"label":"Commercial"
}
]
}
}
I want to be able to filter the images I pull in via the snippet, so that it only pulls in condominiums
for instance.
I’ve tried it a few different ways, with no results. Here’s my mgGetImages snippet. When I remove the &where
statement, it works and successfully pulls in images.
[[!mgGetImages? &resource=`[[*id]]` &imageTpl=`project_gallery.tpl` &where=`{"custom.category":"condominiums"}` &sortBy=`sortorder` &sortDir=`ASC`]]