I want to run a search on Assets that are in use within a particular section. The Assets are added to entries via a Matrix field.
The search term is provided via a url parameter:
{% set searchTerm = craft.request.getParam('q') %}
Somewhat optimistically I tried this:
{% set imagesInUse = craft.assets.relatedTo({
targetElement: craft.entries({
section : 'agency'
}),
field : imageList.keyImage
}) %}
Where imageList is the Matrix field and keyImage is the Assets field. The block name is imageSpread.
This apparently returns nothing.
For the search part, I'm trying to search within 'imagesInUse':
{% for image in imagesInUse.search('*' ~ searchTerm ~ '*').order('score') %} ... {% endfor %}
It looks like a relatively complex query might be required, but I'm not sure where to go from here.