Tagger: How to get all resources from a Group?

I’m trying to display all resources from a Tagger Group by adding this to a pdoResources snippet:


But no luck : ( Maybe I am missing something obvious?

No, this just doesn’t work like this.

Either list all the tags in the group in the property &tags or write your own snippet (as a replacement for TaggerGetResourcesWhere) that queries all the tags in the group and creates the correct subquery ("EXISTS (SELECT 1 FROM `modx_tagger_tag_resources` r WHERE ...)") for pdoResources.

I see, thanks!

Would you happen to know what the custom mySQL query for this would be? I presume you can then just do this inside pdoResources?

&where=`("EXISTS (SELECT 1 FROM `modx_tagger_tag_resources` r WHERE ...)")`

Maybe this snippet code does what you want:

$tagger = $modx->getService('tagger','Tagger',$modx->getOption('tagger.core_path',null,$modx->getOption('core_path').'components/tagger/').'model/tagger/',$scriptProperties);
if (!($tagger instanceof Tagger)) return '';

$field = $modx->getOption('field', $scriptProperties, 'id');
$where = $modx->getOption('where', $scriptProperties, '');
$where = $modx->fromJSON($where);
if ($where == false) {
    $where = array();
$groups = $modx->getOption('groups', $scriptProperties, '');
$groups = $tagger->explodeAndClean($groups);

$c = $modx->newQuery('TaggerTag');
$c->select($modx->getSelectColumns('TaggerTag', 'TaggerTag', '', array('id')));
$c->leftJoin('TaggerGroup', 'Group');
    'Group.id:IN' => $groups,
    'OR:Group.name:IN' => $groups,
    'OR:Group.alias:IN' => $groups,
$tagIDs = $c->stmt->fetchAll(PDO::FETCH_COLUMN, 0);

if (count($tagIDs) == 0) {
    $tagIDs[] = 0;
$where[] = "EXISTS (SELECT 1 FROM {$modx->getTableName('TaggerTagResource')} r WHERE r.tag IN (" . implode(',', $tagIDs) . ") AND r.resource = modResource." . $field . ")";
return $modx->toJSON($where);

@halftrainedharry Thanks a lot! This worked and does exactly what I needed. Thanks again! : )