We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40249
    • 31 Posts
    hello together,

    i'm try to make a cmp in modx 2.3.3 i use code i've already used to build another cmp in modx 2.2 but i always get a 500 Error in my browser and this error in my error log

    Class 'RatingIndexManagerController' not found in /core/model/modx/modmanagerresponse.class.php on line 185

    and

    file structure is the following

    assets/components/rating/css/
    assets/components/rating/img/
    assets/components/rating/js/home.js

    core/components/rating/index.class.php
    core/components/rating/model/controllers/home.class.php
    core/components/rating/model/rating/mysql/rating.class.php
    core/components/rating/model/rating/mysql/rating.map.inc.php
    core/components/rating/model/rating/metadata.mysql.php
    core/components/rating/model/rating/rating.class.php
    core/components/rating/model/rating/rating.mysql.schema.xml

    i added a namespace "rating" and added the path to the component folders

    then i added a menu entry with action "index" and namespace "rating"

    the index.class.php looks like this


    <?php
    /**
     * The abstract Manager Controller.
     * In this class, we define stuff we want on all of our controllers.
     */
    abstract class ratingManagerController extends modExtraManagerController {
        public $modx = null;
        public $config = array();
        public $output = null;
    
    
        /**
         * Default constructor for rating
         *
         * @constructor
         * @param modX &$modx A reference to a modX instance.
         * @param array $config (optional) Configuration properties.
         * @return rating
         */
        function __construct(modX &$modx,array $config = array()) {
            $this->modx =& $modx;
    
            $corePath = $modx->getOption('rating.core_path',null,$modx->getOption('core_path').'components/rating/');
            $assetsUrl = $modx->getOption('rating.assets_url',null,$modx->getOption('assets_url').'components/rating/');
    
            $this->config = array_merge(array(
                'corePath' => $corePath,
                'modelPath' => $corePath.'model/',
                'processorsPath' => $corePath.'processors/',
                'controllersPath' => $corePath.'controllers/',
                'includesPath' => $corePath.'includes/',
    
                'baseUrl' => $assetsUrl,
                'cssUrl' => $assetsUrl.'css/',
                'jsUrl' => $assetsUrl.'js/',
                'connectorUrl' => $assetsUrl.'connector.php',
            ),$config); 
    
            $this->modx->addPackage('rating',$this->config['modelPath']);
            $this->modx->lexicon->load('rating:default');
        } 
        /**
         * Initializes the main manager controller. You may want to load certain classes,
         * assets that are shared across all controllers or configuration. 
         *
         * All your other controllers in this namespace should extend this one.
         *
         * In this case we don't do anything useful, but as you build up more complex
         * extras, it helps to enforce this structure to make it easier to maintain.
         */
        public function initialize() { 
            /*
            $this->addHtml('<script>
              Ext.onReady(function() {
                var myPanel = new Ext.Panel({
                    renderTo : document.body,
                    height   : 50,
                    width    : 150,
                    title    : 'Simple Panel',
                    html     : 'This is my content',
                    frame    : true
                });
            }); 
            </script>');
            */
        }
        /**
         * Defines the lexicon topics to load in our controller.
         * @return array
         */
        public function getLanguageTopics() {
            return array('rating:default');
        }
        /**
         * We can use this to check if the user has permission to see this controller
         * @return bool
         */
        public function checkPermissions() {
            return true;
        }
    }
    /**
     * The Index Manager Controller is the default one that gets called when no
     * &action parameter is passed  We use it to define the default controller
     * which will then handle the actual processing.
     *
     * It is important to name this class "IndexManagerController" and making sure
     * it extends the abstract class we defined above 
     */
    class IndexManagerController extends ratingManagerController {
        /**
         * Defines the name or path to the default controller to load.
         * @return string
         */
        public static function getDefaultController() {
            return 'home';
        }
    }
    


    if i change the line
    class IndexManagerController extends ratingManagerController {
    to
    class RatingIndexManagerController extends ratingManagerController {

    i don't get any errors anymore but a blank manager page.

    anyone got a idea?
      • 50816
      • 12 Posts
      Hi Degoya,

      Did you figure out how to create your CMP? Apparently, they changed how the file structure works starting with version 2.3+. (See this tutorial: https://rtfm.modx.com/revolution/2.x/developing-in-modx/advanced-development/custom-manager-pages/custom-manager-pages-in-2.3)

      The index.class.php does not seem to be necessary anymore and you can definde the manager action directly in the menu entry.

      Did you figure out, where the model can be initialized?