public function prepareQueryAfterCount(xPDOQuery $c) { $c->select($this->modx->getSelectColumns('galItem', 'galItem')); $c->select(array('AlbumItems.rank', 'album' => 'Album.id', '( SELECT GROUP_CONCAT(Tags.tag) FROM ' . $this->modx->getTableName('galTag') . ' AS Tags WHERE Tags.item = galItem.id ) AS tags')); $c->groupBy('id'); return $c; }