I wanted GalleryAlbums to return the count of the number of items in a gallery, so I could display this as part of the row template.
After some reading up of the modx engine, I believe I have done what I needed.
The code modifies the GalleryAlbum snippet as follows:
foreach ($albums as $album) {
$albumArray = $album->toArray();
$c = $modx->newQuery('galItem');
$c->innerJoin('galAlbumItem','AlbumItems');
$c->where(array(
'AlbumItems.album' => $album->get('id'),
));
$c->sortby($albumCoverSort,$albumCoverSortDir);
$c->limit(1);
$coverItem = $modx->getObject('galItem',$c);
/* NEW LINE - GET ITEM COUNT */
$albumArray['albumCount'] = $modx->getCount('galItem',$c);
if ($coverItem) {
$albumArray['image'] = $coverItem->get('thumbnail',$thumbProperties);
}
$albumArray['cls'] = $rowCls;
$albumArray['idx'] = $idx;
$albumArray['showName'] = $showName;
$albumArray['albumRequestVar'] = $albumRequestVar;
$output[] = $gallery->getChunk($rowTpl,$albumArray);
$idx++;
}
The highlighted line is my addition.
Feel free to test - it works for me on my sites, and I have tested locally, on a live site, etc. - but usual caveats apply!
If someone could point me in the right direction for submitting this as suggestion for future releases, I’ll happily file a request....