Trying to create a Snippet that grabs all of the Contexts except ’web’ and cycles through them. Can’t find anything in the API to do this. Any ideas?
Ah. I am actually just trying to get the name of the context, not the object itself. Sorry for not being descriptive.
Try this:
<?php
$c = $modx->newQuery('modContext');
$c->where(array(
'key:!=' => 'web',
));
$contexts = $modx->getCollection('modContext',$c);
$contextNames = array();
foreach($contexts as $context) {
$contextNames[] = $context->get('key');
}