$modx->context->key
return the correct value !
<?php /* * Usage [[getContext? &id=``]] */ //retrieve ID or use current resource $id = (!empty($id) ? $id : $modx->resource->get('id')); //retrieve context $page = $modx->getObject('modResource', $id); $output = $page->get('context_key'); //return output return $output;
And for the people who want to retrieve the current context by a given ID I created the following simple snippet with Pandy06269's tip.
<!--?php /* * Usage [[getContext? &id=``]] */ //retrieve ID or use current resource $id = (!empty($id) ? $id : $modx--->resource->get('id')); //retrieve context $page = $modx->getObject('modResource', $id); $output = $page->get('context_key'); //return output return $output;