-
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).
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!
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!
-
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’]
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!
That sounds right to me, unless you just want to give it a menuindex of 99 or 999.
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!
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!