We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 24714
    • 19 Posts
    My question is...

    How does it work actually?
    I can see this line for instance
    $modx->request->handleRequest(array('location' => 'browser'));

    but i cant see niether arguments in the handleRequest method nor smth like func_get_args...

    Just cant make both ends meet =)
      • 3749
      • 24,544 Posts
      This is in the modConnectorRequest class file. It's the only example I could find of a handleRequest() method with args:

      /**
           * Handles all requests specified by the action param and prepares for loading.
           *
           * @access public
           * @param string $location The base subdirectory in which to look for the processor.
           * @param string $action The requested processor to load.
           */
          public function handleRequest(array $options = array()) {
              if (isset($options['action']) && !is_string($options['action'])) return false;
              if ((!isset($options['action']) || $options['action'] == '') && isset($_REQUEST['action'])) {
                  $options['action'] = $_REQUEST['action'];
              }
              $options['action'] = strtolower($options['action']);
      
              $this->loadErrorHandler();
      
              /* Cleanup action and store. */
              $this->prepareResponse($options);
          }
        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
        • 24714
        • 19 Posts
        ffs i was trepanatinf the modRequest class for an hour =)

        thx a lot
          • 24714
          • 19 Posts
          btm here is instantiation of the class in inedx.php

          $connectorRequestClass = $modx->getOption('modConnectorRequest.class',null,'modConnectorRequest');
          $modx->config['modRequest.class'] = $connectorRequestClass;
          $modx->getRequest();


          at last i know how it works after all =))))
          thx a lot again... it was a little dumb of me =)
            • 3749
            • 24,544 Posts
            I spent some time looking at the modRequest class too, before I thought of doing a global search for "function handleRequest". wink
              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
              • 37286
              • 160 Posts
              I'm having a hard time figuring out how to push the post from the connector file to the processor in the web context. It seems like a no brainer after putting together the manager, but I'm just missing something.

              My connector:
              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('addon.core_path',null,$modx->getOption('core_path').'components/addon/');
              require_once $corePath.'model/addon/addon.class.php';
              $modx->addon= new Addon($modx);
              
              $modx->lexicon->load('addon:default');
              
              /* handle request */
              $path = $modx->getOption('processorsPath',$modx->addon->config,$corePath.'processors/');
              $modx->request->handleRequest(array(
                  'processors_path' => $path,
                  'location' => '',
              ));
              


              And my JQuery that executes my post:
                  $('#fileupload').bind('fileuploadsend', function (e, data) {
                      if (data.dataType.substr(0, 6) === 'iframe') {
                          var target = $('<a/>').prop('href', data.url)[0];
                          if (window.location.host !== target.host) {
                              data.formData.push({
                                  name: 'redirect',
                                  value: redirectPage,
                                  action:'web/items/create'
                              });
                          }
                      }
                  });
              


              And I placed just a simple error logging in the processor file:
              $modx->log(modX::LOG_LEVEL_ERROR,'[addon] loaded create processor');
              return 'test';
              


              While it runs the code in my connector ( I placed the same error post while I was testing ), it never makes it to my processor. I have tried changing the processor file name to create.class.php, even calling 'web/items/create.php' in the javascript. I've been working on this off and on for days, and I just need someone smarter than me to tell me what I'm doing wrong.
                • 3548
                • 102 Posts
                Why would you do this this way?

                You can simply load your addon in the snippet, put that snippet into resource and do what ever you want. I don't see benefits from using connectors/processors in web context, at least benefits (restrict access, check permissions) are more easily achieved in snippet/resource way.

                But if you are curious why your code doesn't work, I believe that you cannot access connectors (or was it processors?) without mgr session.

                Regards

                  Antonio Zdilar
                  linearvector.com
                  • 37286
                  • 160 Posts
                  I'm working on an extra, which I thought would be easier for the people installing it to not have to have the extra steps and muddy up there resource tree. Now that you point it out, I have used other extras that do this very same thing.

                  Thanks
                    • 37031
                    • 93 Posts
                    Quote from: blankcheck at Feb 06, 2012, 11:24 PM

                    ...
                    But if you are curious why your code doesn't work, I believe that you cannot access connectors (or was it processors?) without mgr session.
                    ...

                    This helped me a lot! Thank you! I was trying to figure out why my processor wasn't filling my grid. It seems I was logged into both web and mgr contexts so after flushing all sessions and logging into just the mgr context it worked smiley