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

    I have some troubles trying to add a CMP for my extra. As Shaun McCormick's tutorial says, I added an index.class.php :

    <?php
    	require_once dirname(__FILE__) . '/model/importusersx/importusersx.class.php';
    	class IndexManagerController extends modExtraManagerController {
    		public static function getDefaultController() { return 'home'; }
    	}
    
    	abstract class ImportUsersXManagerController extends modManagerController {
    		
    		public $importusersx;
    		public function initialize() {
    			$this->importusersx = new ImportUsersX($this->modx);
    			$this->addCss($this->importusersx->config['cssUrl'].'mgr.css');
    			$this->addJavascript($this->importusersx->config['jsUrl'].'mgr/importusersx.js');
    			$this->addHtml('<script type="text/javascript">
    			Ext.onReady(function() {
    				ImportUsersX.config = '.$this->modx->toJSON($this->importusersx->config).';
    			});
    			</script>');
    			return parent::initialize();
    		}
    		public function getLanguageTopics() {
    			return array('importusersx:default');
    		}
    		public function checkPermissions() { return true;}
    	}


    and a home.class.php :

    <?php
    	class ImportUsersXHomeManagerController extends ImportUsersXManagerController {
        public function process(array $scriptProperties = array()) {
     
        }
        public function getPageTitle() { return $this->modx->lexicon('importusersx'); }
        public function loadCustomCssJs() {
            //$this->addJavascript($this->doodles->config['jsUrl'].'mgr/widgets/doodles.grid.js');
            $this->addJavascript($this->importusersx->config['jsUrl'].'mgr/widgets/home.panel.js');
            $this->addLastJavascript($this->importusersx->config['jsUrl'].'mgr/sections/index.js');
        }
        echo $this->importusersx->config['templatesPath'].'home.tpl';exit();
        public function getTemplateFile() { return $this->importusersx->config['templatesPath'].'home.tpl'; }
    }


    My CMP wasn't displayed so I tried to found why and it appears that home.class.php return an 500 error. It doesn't work even with an echo('try');exit(); at the second line for testing.

    Someone knows why ?

    I work with revo 2.2.1-dev.

    Thanks ! [ed. note: tzoreol last edited this post 14 years, 6 months ago.]
      • 3749
      • 24,544 Posts
      In the second example, your echo statement would have to be inside one of the class functions.

      Where it is now, it's not valid PHP code.


      As for the first example, it's valid, but you have an abstract class, which can't be instantiated. That could be the problem.


      ---------------------------------------------------------------------------------------------------------------
      PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
      MODX info for everyone: http://bobsguides.com/modx.html
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting