/** * Loads a PimpMyMatrix.FieldManipulator() for the corrext context */ public function loadFieldManipulator($context) { // Get global data $globalPimpedBlockTypes = craft()->pimpMyMatrix_blockTypes->getBlockTypesByContext('global', 'context'); // Get all the data for the entrytype context regardless of entrytype id $mainContext = explode(':', $context)[0]; $contextPimpedBlockTypes = craft()->pimpMyMatrix_blockTypes->getBlockTypesByContext($mainContext, 'context', true); $pimpedBlockTypes = array_merge($globalPimpedBlockTypes, $contextPimpedBlockTypes); if ($pimpedBlockTypes) { craft()->templates->includeCssResource('pimpmymatrix/css/pimpmymatrix.css'); // Set up the groups craft()->templates->includeJsResource('pimpmymatrix/js/fieldmanipulator.js'); $settings = array('blockTypes' => $pimpedBlockTypes, 'context' => $context); craft()->templates->includeJs('new PimpMyMatrix.FieldManipulator(' . JsonHelper::Encode($settings) . ');'); } }