We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3632
    • 22 Posts
    Had exactly the same thought after I posted. Still, in all the components I looked at they seem to be extending the MODx class so I think I’ll try to figure out all that instead so I can get all that ModX UI goodness.
      • 24865
      • 289 Posts
      Don’t try to reinvent the wheel, I’ve already done it the perfect example has been already made (the manager itself uses it for Javascript based Lexicon entries). I’ve modified it to suite my needs and to be extended.

      The template for the config file:
      var cmbConfig = function() { return {structure: %s, config: %s, post: %s, get: %s, auth: %s} };


      In a custom initializer from my main class, I’ve built the following:

      $config = file_get_contents($this->structure['model'].'callmeback/config.template.php');
      $config = sprintf($config, json_encode($this->structure), json_encode($this->config), json_encode($_POST), json_encode($_GET), (string) '"'.trim($this->modx->site_id).'"');

      The first line simply fetches the config template, and using sprintf I replace all that I need. Reasigning it to the $config variable saves time, space and memory. Next, I return it (sort of a dump, since I "echo" the initializer class, which this is in).

      As so:

      echo $modx->cmb->initialize('javascript:config');

      Action: javascript
      Method: config

      All the examples on how to initialize a config core/connector core, is already in the connectors/index.php file. smiley

      Good luck!
        @MarkGHErnst

        Developer at Adwise Internetmarketing, the Netherlands.
        • 28215
        • 4,149 Posts
        FYI, all requests variables should already be in the JS object "MODx.request" (ie, MODx.request.a, MODx.request.id), and the site ID is in MODx.siteId
          shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
          • 24865
          • 289 Posts
          Depends which version of the Javascript lib you’re using? I dislike the MODext version, simply because it is an addition to the functionality of ExtJS, but then again, I use both. At the backend I simply use MODext, but on my frontend I like to use plain old ExtJS.

          Then again, my way allows for even more data to be sent to the frontend... Naturally, if you have some examples I’d be happy to revise my solution and incorporate yours.
            @MarkGHErnst

            Developer at Adwise Internetmarketing, the Netherlands.
            • 28215
            • 4,149 Posts
            Quote from: ReSpawN at Sep 19, 2010, 02:56 PM

            Depends which version of the Javascript lib you’re using? I dislike the MODext version, simply because it is an addition to the functionality of ExtJS, but then again, I use both. At the backend I simply use MODext, but on my frontend I like to use plain old ExtJS.

            Then again, my way allows for even more data to be sent to the frontend... Naturally, if you have some examples I’d be happy to revise my solution and incorporate yours.
            Oh, front-end? Sorry - thought you only meant back. Yes, modExt is definitely not meant for front-end deployments.
              shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
              • 27985
              • 54 Posts
              Quote from: ReSpawN at Aug 11, 2010, 05:41 AM

              When I finally figure this out I’m gonna write some wicked ass tutorial about it, because this does not need to be so complex and annoyingly difficult.

              So, how about that tutorial? grin
                MODx 2.0.6
                PHP 5.3.3
                MySQL 5.1.50
                • 24865
                • 289 Posts
                Hehe whoops, completely slipped my mind! I’m currently involved with some big projects so it’s being postponed... Until further notice. ;-)
                  @MarkGHErnst

                  Developer at Adwise Internetmarketing, the Netherlands.
                  • 27985
                  • 54 Posts
                  Cool. Well, maybe this is the problem I am trying to solve anyways: http://modxcms.com/forums/index.php/topic,44245.0.html

                  I too make a good-natured proposal to distribute the knowledge that I gain. smiley
                    MODx 2.0.6
                    PHP 5.3.3
                    MySQL 5.1.50
                    • 24865
                    • 289 Posts
                    Are you still having that problem? I’ve figured it out a couple of weeks ago, although I should read in the subject before I get started. smiley
                      @MarkGHErnst

                      Developer at Adwise Internetmarketing, the Netherlands.
                      • 39535
                      • 39 Posts
                      I had this repsonse:
                      {"success":false,"message":"Access denied.","total":0,"data":[],"object":{"code":401}}

                      As you see I had "object":{"code":401} in my JSON response when you had "object":[]. Interesting.

                      My problem was that I performed AJAX request by jQuery $.ajax() form my CMP (didn't check it from front-end).
                      But after reading this thread I changed $.ajax() to Ext.Ajax.request(). And that start to work. Awesome, so you helped me)

                      Could anyone explain me why did that happen?

                      Also how can I prevent my connector to process processor-php-file (that it connects to) when request to connector came from front-end?