We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 47166
    • 9 Posts
    Hello!

    I'm having a problem with a grid in a CMP.

    The "Doodle"-Tutorial worked fine, so I set up a clear MODX development installation to start developing an extension in.
    Everything fine, so far, too. But: The grid, I want to fill, stays empty.

    Checking the calls using FireBug showed, that the "connector.php" returns an unsuccessfull state 401.

    My directory structure looks as follows:
    http://domain.local
    +-> /dev
    |   +-> /dbbbookings
    |       +-> ...
    +-> /modx

    In /dev/dbbbookings my extension to develop resides, while the MODX installation is under /modx.

    Here comes the code of my grid, which is in file "resourcetype.grid.js".
    DBBBookings.grid.ResourceType = function(config) {
        config = config || {};
        Ext.applyIf(config, {
            id: 'dbbbookings-grid-resourcetype',
            url: DBBBookings.config.connectorUrl,
            baseParams: { action: 'mgr/dbbbooking/getResourceTypeList' },
            fields: ['id', 'name', 'menu'],
            paging: true,
            remoteSort: true,
            anchor: '97%',
            autoExpandColumn: 'name',
            columns: [{
                header: _('id'),
                dataIndex: 'id',
                sortable: true,
                width: 60
            },
            {
                header: _('dbbbookings.name'),
                dataIndex: 'name',
                sortable: true,
                width: 350,
                editor: { xtype: 'textfield' }
            }]
        });
        DBBBookings.grid.ResourceType.superclass.constructor.call(this, config);
    };
    Ext.extend(DBBBookings.grid.ResourceType, MODx.grid.Grid);
    Ext.reg('dbbbookings-grid-resourcetype', DBBBookings.grid.ResourceType);


    My "home.panel.js" contains the code
    DBBBookings.panel.Home = function(config) {
        config = config || {};
        Ext.apply(config, {
            border: false,
            baseCls: 'modx-formpanel',
            cls: 'container',
            items: [{
                html: '<h2>'+_('dbbbookings.management')+'</h2>',
                border: false,
                cls: 'modx-page-header'
            },
            {
                xtype: 'modx-tabs',
                defaults: { border: false, autoHeight: true },
                border: true,
                items: [...
                {
                    title: _('dbbbookings.options'),
                    defaults: { autoHeight: true },
                    items: [{
                        html: '<p><strong>'+_('dbbbookings.resource_types')+'</strong></p><p>'+_('dbbbookings.resource_types_desc')+'</p>',
                        border: false,
                        bodyCssClass: 'panel-desc'
                    },
                    {
                        xtype: 'dbbbookings-grid-resourcetype',
                        cls: 'main-wrapper',
                        preventRender: true
                    },...]
                }],
                listeners: {
                    'afterrender': function(tabPanel) {
                        tabPanel.doLayout();
                    }
                }
            }]
        });
        DBBBookings.panel.Home.superclass.constructor.call(this, config);
    };
    Ext.extend(DBBBookings.panel.Home, MODx.Panel);
    Ext.reg('dbbbookings-panel-home', DBBBookings.panel.Home);


    And my "connector.php" looks as follows:
    <?php
    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('dbbbookings.core_path', null, $modx->getOption('core_path').'components/dbbbookings/');
    require_once $corePath.'model/dbbbookings/dbbbookings.class.php';
    $modx->dbbbookings = new DBBBookings($modx);
     
    $modx->lexicon->load('dbbbookings:default');
     
    // Handle request.
    $path = $modx->getOption('processorsPath', $modx->dbbbookings->config, $corePath.'processors/');
    $modx->request->handleRequest(array(
        'processors_path' => $path,
        'location' => '',
    ));


    The part of the SQL-Schema, which is interesting for the code above is:
    <?xml version="1.0" encoding="UTF-8"?>
    <model package="dbbbookings" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.0">
        <object class="DBBBookingsResourceType" table="dbbbookings_resource_type" extends="xPDOSimpleObject">
            <field key="name" dbtype="varchar" precision="32" phptype="string" null="false" default="" />
        </object>


    And my processor, that should be called, resides in file "getresourcetypelist.class.php" and contains
    <?php
    class DBBBookingsGetResourceTypeListProcessor extends modObjectGetListProcessor {
        public $classKey = 'DBBBookingsResourceType';
        public $languageTopics = array('dbbbookings:default');
        public $defaultSortField = 'name';
        public $defaultSortDirection = 'ASC';
        public $objectType = 'dbbbookings.DBBBookingsResourceType';
    }
    return 'DBBBookingsGetResourceTypeListProcessor';


    I checked for any "Doodle"-stuff in my new code files, cross checked anything, any line, but unfortunately I cannot find any reason for this behaviour.

    FireBug also says that "this.table is undefined", but I think this is an preceeding error, which occures because of the unsuccessfull state of the connector.

    Does anyone has a clue? I would really appreciate any help.

    Thanks in advance,
    Dennis [ed. note: blnguy79 last edited this post 12 years, 6 months ago.]
      • 4172
      • 5,888 Posts
      1. does it request the correct url to your connector?

      if yes, try to debug the connector line by line with a die('something');

      2. does it run the processor?

      again, try to debug the processor.

      Or, if you want to go the easier way, you can try MIGXdb for building your first custom - CMP
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 47166
        • 9 Posts
        Hello Bruno17,

        thank you for the quick reply.

        At 1: Yes, it runs the correct connector. Tried to log something in the MODX error log and tried to let the script die with a message. Both things are working as expected.

        At 2: How can I find out, if the processor is run? It points to the correct path, but as far as I know, the processor's call is done via AJAX and so it does not occur anywhere where I could track it.
        But I think, that the processor is not run. Before the "return" statement in this .php file I tried to delete a file, that resides in the "/dev/dbbbookings" directory. After refreshing the page the file still exists.

        I also checked the extension's "config.core.php" and defined a value, that is only contained in that file. The connector has access to this value and echoes it without any problems to the debugging console.

        Thank you for the hint with the generator extension, too. But due to the fact, this extension may become quite complex and I want to get known to the development within the MODX framework, I would really prefer to get rid of this problem just by writing code on my own.
        As stated in my former post, the simple Doodle thing works totally fine and actually this extension is not even that "complex". wink

        Thanks,
        Dennis
          • 4172
          • 5,888 Posts
          for a quick response-check with firebug, you can add a function to the processor, like that:

              public function setProperties($properties) {
                  echo 'processor is running';
                  die(); 
              }


          setProperties is the first and only method, called from modProcessor::__construct
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 47166
            • 9 Posts
            Thank you,

            I will try this immediately tomorrow morning and let you know about the results.

            Dennis
              • 3749
              • 24,544 Posts
              I you use Chrome's dev. tools (Ctrl-Shift-i), you can see all the traffic on the network tab, including what's being passed both ways between the connector and the processor.

              http://bobsguides.com/blog.html/2013/05/22/debugging-cmps-a-horror-story/
                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
                • 47166
                • 9 Posts
                Hello everybody!

                I found kinda solution for the problem.

                It seems, the fact my "dev" directory is not a part of the "modx" directory caused the problem.
                The authorization done by session was not valid, due the request for the connector came from "outside".

                I now moved the "dev" directory and all subdirectories to "modx", applied path and url settings and everything works fine.

                This "solution" works best for me, due I do not want my session data being stored outside the framework.

                Thank you all for your ideas and input. I think this will be helpfull anyway on my way. smiley

                Dennis