diff --git a/core/components/tagger/elements/snippets/taggergetresourceswhere.snippet.php b/core/components/tagger/elements/snippets/taggergetresourceswhere.snippet.php index 7f43036..de3ad85 100644 --- a/core/components/tagger/elements/snippets/taggergetresourceswhere.snippet.php +++ b/core/components/tagger/elements/snippets/taggergetresourceswhere.snippet.php @@ -15,6 +15,7 @@ * &tagField string optional Field that will be used to compare with given tags. Default: alias * &matchAll int optional If set to 1, resource must have all specified tags. Default: 0 * &field string optional modResource field that will be used to compare with assigned resource ID + * &class string optional * * USAGE: * @@ -32,6 +33,7 @@ $matchAll = (int) $modx->getOption('matchAll', $scriptProperties, 0); $field = $modx->getOption('field', $scriptProperties, 'id'); $where = $modx->fromJSON($where); +$class = $modx->getOption('class', $scriptProperties, 'modResource'); if ($where == false) { $where = array(); } @@ -133,9 +135,9 @@ } if ($matchAll == 0) { - $where[] = "EXISTS (SELECT 1 FROM {$modx->getTableName('TaggerTagResource')} r WHERE r.tag IN (" . implode(',', $tagIDs) . ") AND r.resource = modResource." . $field . ")"; + $where[] = "EXISTS (SELECT 1 FROM {$modx->getTableName('TaggerTagResource')} r WHERE r.tag IN (" . implode(',', $tagIDs) . ") AND r.resource = ".$class."." . $field . ")"; } else { - $where[] = "EXISTS (SELECT 1 as found FROM {$modx->getTableName('TaggerTagResource')} r WHERE r.tag IN (" . implode(',', $tagIDs) . ") AND r.resource = modResource." . $field . " GROUP BY found HAVING count(found) = " . $tagsCount . ")"; + $where[] = "EXISTS (SELECT 1 as found FROM {$modx->getTableName('TaggerTagResource')} r WHERE r.tag IN (" . implode(',', $tagIDs) . ") AND r.resource = ".$class."." . $field . " GROUP BY found HAVING count(found) = " . $tagsCount . ")"; } -return $modx->toJSON($where); \ No newline at end of file +return $modx->toJSON($where);