I have articles with a multi-select named theme.
This works fine in a template:
{% set entries = craft.entries.section('article').search('theme:themeFoobar') %}
<p>{{ entries | length }}</p>
I'm working on a plugin to create a custom source containing only those articles that have themeFoobar selected in their multi-select, this is what I have:
public function modifyEntrySources(&$sources, $context)
{
$sources[] = array('heading' => 'Themes');
$sources['theme:foobar'] = array(
'label' => 'Theme: Foobar',
'criteria' => array(
'section' => 'article',
'search' => 'theme:themeFoobar'
)
);
}
The result of this is that the source contains all articles, it looks like the search criteria is completely ignored.
Is search not the correct criteria to use here? Is there another criteria I can use to find only the articles with themeFoobar selected in the multi-select?
Further information
The multi-select used to be just a dropdown. When it was a dropdown, this plugin worked fine:
public function modifyEntrySources(&$sources, $context)
{
$sources[] = array('heading' => 'Themes');
$sources['theme:foobar'] = array(
'label' => 'Theme: Foobar',
'criteria' => array(
'section' => 'article',
'theme' => 'themeFoobar'
)
);
}
'search' => 'theme:*themeFoobar*'? The multi select stores the array of values as a JSON string to the database. – carlcs Mar 03 '16 at 13:00