We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22303 MODX Staff
    • 10,725 Posts
    modActions are for manager views, much like modResource is for front-end views. Connectors have nothing to do with this organization and are context agnostic; they are like web services. Connectors are called by name and are executed in the mgr context by default, unless you pass a REQUEST parameter ’ctx’ with the key of the context you are calling the connector from (i.e. a custom manager action or a custom front-end resource). Connectors should always run in the context they are being called from; this is their execution context which defines how the manager interface interacts with it, it’s security model, etc.

    Managing Resources for front-end contexts from custom components is a completely separate issue and has nothing to do with execution contexts. It has to do with managing data that can be isolated and manipulated within a data structure known as contexts. You will need to figure out how your component will manage bulk changes to Resources or other objects that are affected by contexts, including how to look at and manipulate data from various contexts while executing a process in the appropriate context (i.e. mgr or some other custom administration context you might define).
      • 26903
      • 1,336 Posts
      I’m going to look at a simple example, on the reports page I can see the modx log, this has a button on it called ’clear’, when I press this it works, i.e it clears the log. This works, like the rest of the manager, so I’ll look at its js and its connector. if I apply what its doing to my ’change’ button on my Change Template page it should also work, i.e find and execute my backend processor for this button. This is where I’m currently stuck.
        Use MODx, or the cat gets it!
        • 26903
        • 1,336 Posts
        You should be just able to include the connectors/index.php file to instantiate the correct context.
        Aaaaargh!!! yes, I should have done the diff between the latest and last version earlier. I can see now the manual instantiation of the modconnectorresponse class, this is what my connector index.php is lacking for one.

        I’d like to include this rather than update my own but what’s the best way to do this? I’m in /assets/components/docmanager/core/connectors, I could just include it from /connectors but can this directory not be moved during the install process? What I’m saying is what’s the best/recommended way to do this?
          Use MODx, or the cat gets it!
          • 22303 MODX Staff
          • 10,725 Posts
          For global connectors for a configuration:
          MODX_CONNECTORS_PATH
          MODX_CONNECTORS_URL

          Customizable by context:
          $modx->config[’connectors_path’]
          $modx->config[’connectors_url’]
            • 26903
            • 1,336 Posts
            Another ’learn as I go question’ :-

            I’m now packaging what I’ve done so far with docmanager so I can transport it, install it and work on it on more than one box. Ok, I’ve created the top menu and the sub menus, linked them together in a resolver, this all works Ok. I found however that to put the Doc Manager top menu entry into its correct position i.e. at the end of the top menu I had to do a getCollection of modMenus whose parents are 0, i.e top menu’s and find the highest menuindex, increment this and set this value in the Doc Manager menu as its menuindex, this will always put it at the end of the top menu line.

            Does this sound right? Is there a better way to do this, it seems a bit cumbersome.
              Use MODx, or the cat gets it!
              • 3749
              • 24,544 Posts
              That sounds right to me, unless you just want to give it a menuindex of 99 or 999. smiley
                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
                • 28215
                • 4,149 Posts
                Quote from: shamblett at Feb 09, 2009, 02:43 PM

                I’m now packaging what I’ve done so far with docmanager so I can transport it, install it and work on it on more than one box. Ok, I’ve created the top menu and the sub menus, linked them together in a resolver, this all works Ok. I found however that to put the Doc Manager top menu entry into its correct position i.e. at the end of the top menu I had to do a getCollection of modMenus whose parents are 0, i.e top menu’s and find the highest menuindex, increment this and set this value in the Doc Manager menu as its menuindex, this will always put it at the end of the top menu line.

                Does this sound right? Is there a better way to do this, it seems a bit cumbersome.
                No better way. smiley

                I usually just do a getCount in an install resolver:

                $resourceCount = $xpdo->getCount('modMenu',array(
                   'parent' => 0,
                ));
                

                This does it. By the way - the ’Components’ menu is meant to be there for you to put menu items in. However, if you’re doing more than 1 modAction for your docmanager, then you could do more than one.

                Supposedly the menu can go more than 2 levels CSS wise, but I’m not sure if we’ve built that into the logic yet. You could test it. smiley
                  shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
                  • 26903
                  • 1,336 Posts
                  I usually just do a getCount in an install resolver:
                  , yes this is a bit better assuming the menuindex values are contiguous, which is probably OK here, thanks.

                  Initially I wanted to use the components menu, but I couldn’t see how to put sub-menus on the Doc Manager component as you say. What I may do as a future release is do this anyway and change the layout to tabbed panes, one for each function, that way only one entry will be needed in components. I also need to add in the ’select from tree’ functionality as well, later.
                    Use MODx, or the cat gets it!
                    • 26903
                    • 1,336 Posts
                    For global connectors for a configuration:
                    MODX_CONNECTORS_PATH
                    MODX_CONNECTORS_URL

                    Just tried this, changed my changetemplate.php connector code from
                    require_once dirname(__FILE__).'/index.php';
                    which included my local index.php to
                    require_once (MODX_CONNECTORS_PATH . '/index.php');
                    and it blows up with a ’failed to open stream’ error, the constant is not defined for some reason.
                      Use MODx, or the cat gets it!
                      • 22303 MODX Staff
                      • 10,725 Posts
                      Quote from: shamblett at Feb 10, 2009, 05:15 AM

                      Just tried this, changed my changetemplate.php connector code from
                      require_once dirname(__FILE__).'/index.php';
                      which included my local index.php to
                      require_once (MODX_CONNECTORS_PATH . '/index.php');
                      and it blows up with a ’failed to open stream’ error, the constant is not defined for some reason.
                      Oh boy, chicken and the egg game; you have to include the index.php file in your connector before MODx is loaded. This means you need to place your connectors in the appropriate place in the connectors directory and include it relatively. Otherwise, you need to create your own connector gateway where your connectors will live.