I’m trying to get all resources that are a ‘Collection’. (from the collections extra)
Step to reproduce
Strangely enough running this code
$docs = $modx->getCollection(‘CollectionContainer’);
foreach ($docs as $doc){
$o .= $doc->get(‘id’);
}
returns ALL pages in the context not just the ones that have class_key CollectionContainer.
Any one know why that is?
Hi,
you’re right $docs = $modx->getCollection(‘CollectionContainer’, array('class_key' => 'CollectionContainer'));
works. But i find it not logical. Whats the use of using a class if getCollection will use its Super ?
I don’t really know why that’s the case, but I’ve made that mistake myself.
I think it has to do with the architecture of xPDO. Even though modDocument and Article are classes in their own right, queries for them always seem to look for modResource objects.