We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 45634
    • 23 Posts
    I'm following the tutorial http://rtfm.modx.com/revolution/2.x/case-studies-and-tutorials/developing-an-extra-in-modx-revolution and I contantly run into this "Could not get table class for class:" error from "/assets/components/whisky/connector.php"

    First I tried running thru the tutorial by hand but renaming the model as I wanted - error. Then I tried downloading https://github.com/splittingred/Doodles and installing it - works. Ok. Can I now rename the component and model to what I want? Error.

    What is the best way to debug this error?
    How should the connector.php file be making sure that models in a component are loaded?

    Thanks,

    This question has been answered by jarofgreen. See the first response.

      • 45634
      • 23 Posts
      So the model files are:

      ./core/components/whisky/model
      ./core/components/whisky/model/schema
      ./core/components/whisky/model/schema/whisky.mysql.schema.xml
      ./core/components/whisky/model/whisky
      ./core/components/whisky/model/whisky/whisky.class.php
      ./core/components/whisky/model/whisky/request
      ./core/components/whisky/model/whisky/request/whiskycontrollerrequest.class.php
      ./core/components/whisky/model/whisky/mysql
      ./core/components/whisky/model/whisky/mysql/brand.class.php
      ./core/components/whisky/model/whisky/mysql/brand.map.inc.php
      ./core/components/whisky/model/whisky/metadata.mysql.php
      ./core/components/whisky/model/whisky/brand.class.php


      How does /assets/components/whisky/connector.php know to reference these model files? I couldn't find any code in the Doodle example that suggested how it did that.
        • 40641 ☆ A M B ☆
        • 56 Posts
        Can you provide the content of /assets/components/whisky/connector.php ?
          • 45634
          • 23 Posts
          Attached is ZIP of files, both the original Doodle example that does not throw this error and my changed code that does. I've even been digging down into xPDO source code to try to work out what is going on, and haven't got anywhere! Any suggestions at all appreciated.
          Thanks,
            • 45634
            • 23 Posts
            <?php
            /**
             * Whisky Connector
             *
             * @package whisky
             */
            require_once dirname(dirname(dirname(dirname(__FILE__)))).'/config.core.php';
            require_once MODX_CORE_PATH.'config/'.MODX_CONFIG_KEY.'.inc.php';
            require_once MODX_CONNECTORS_PATH.'index.php';
            
            $corePath = $modx->getOption('whisky.core_path',null,$modx->getOption('core_path').'components/whisky/');
            require_once $corePath.'model/whisky/whisky.class.php';
            require_once $corePath.'model/whisky/brand.class.php';
            $modx->whisky = new Whisky($modx);
            
            $modx->lexicon->load('whisky:default');
            	
            /* handle request */
            $path = $modx->getOption('processorsPath',$modx->whisky->config,$corePath.'processors/');
            $modx->request->handleRequest(array(
                'processors_path' => $path,
                'location' => '',
            ));
              • 40641 ☆ A M B ☆
              • 56 Posts
              Have you manually added the namespace to MODX? I'm assuming you haven't packaged this and installed via the package manager?
                • 45634
                • 23 Posts
                This has not been packaged.
                I took a clean install of modx and for each one (doodle and whisky) manually added the namespace, action and menuitem.

                (Note I didn't add any tables, so when I go to Doodle I get the error "Table 'modx.modx_doodles' doesn't exist" but that's fine, at least it can find the tablename)
                  • 4172
                  • 5,888 Posts
                  you could also try, if you will have more luck, by following this one to create a CMP for managing your custom-tables:

                  http://rtfm.modx.com/extras/revo/migxdb/migxdb.tutorials/migxdb.create-doodles-manager-with-help-of-migxdb
                    -------------------------------

                    you can buy me a beer, if you like MIGX

                    http://webcmsolutions.de/migx.html

                    Thanks!
                    • 45634
                    • 23 Posts
                    So I used Migx to generate the model files, and it generated exactly what I already had. :-(

                    Your instructions seem to start repeating half way throught BTW?

                    Anyone have any ideas?
                    Thanks, James
                      • 18373 ☆ A M B ☆
                      • 3,141 Posts
                      Hi James!

                      Instead of loading model files directly with require, you need to add the package (collection of models; whisky in your case. This is done with $modx->addPackage. I don't have an example at hand because I'm not on my laptop atm, but if you look in the rtfm it should show you how that works.

                      The reason that it can't find the table name is because when loading the model directly it does not load the maps containing all information on table layout.
                        Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

                        Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.