We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 5340
    • 1,624 Posts
    Hi,

    I was looking for a way to read the current context and found the following code in the getresources snippet

        $contextResourceTbl = $modx->getTableName('modContextResource');
        
        /* multiple context support */
        $modx->setLogTarget('ECHO');
        
        if (!empty($context)) {
            $context = explode(',',$context);
            $contexts = array();
            foreach ($context as $ctx) {
                $contexts[] = $modx->quote($ctx);
            }
            $context = implode(',',$contexts);
            unset($contexts,$ctx);
        } else {
            $context = $modx->quote($modx->context->get('key'));
        }



    I can understand the "else" part but I’m not sure what’s done in the first branch of the "if".

    Looks like there is a possibility to have multiple context at the same time but why would you need that. How would it work?

    Thanks