Office extra is a modular system in which there can be any number of parts (controllers). There are 4 of them in the standard set:
- Auth - authorization through email
- Profile - work with a user's profile
- miniShop2 - output of the user account MS2
- RemoteAuth - authorization on one site through another
The component itself has snippet Office, which calls for the needed controller and sends all the indicated parameters to it. That is, all possible settings, chunks and other properties depend on the controller and are not written into the snippet. For example, here is a call for all 3 controllers at once on one page.
[[!Office?&action=`Auth`]] [[!Office?&action=`Profile`]] [[!Office?&action=`miniShop2`]]
For standard controllers there are special snippets with parameters written into them for the sake of convenience. For work they still call for Office snippet.
Setting the controllers
Everything you tell the snippet is sent to the controller. It makes decisions about what is useful for it itself. All standard scripts and styles that are necessary for work are registered through system settings, like in miniShop2.
For example, you can change the way the user account miniShop2 looks through system setting office_extjs_css
The old look (
The new look (
By default the appearance is chosen due to what version of MODX is installed - 2.2 or older.
Generally speaking, controller is an ordinary php class, which inherits standard class from Office.
All classes are located in directory
/core/components/office/controllers/. Due to the modular architecture you can easily change any one of them.
You should just make a copy, rename it and call for it:
[[!Office? &action=`AuthCopy` ]]
You can also register controllers from the addons you download in Office.
Extension by extra components
Extra components can register their own controllers by adding their directory to system parameter office_controllers_paths.
To make this work easier it is better to use methods of Office::addExtenstion() и Office::removeExtension() - the principle is the same as when you register models of components in MODX.
You can see an example in a draft for addons design modExtra:
Work with records modExtra in the admin space
Work with records modExtra from the outside
A registered controller is shown by its name. In this case it is:
You do not have to use Ext JS, it is just an example of the opportunities you have.
Here is everything you need for editing records modExtra on the site's frontend на фронтенде сайта, by one commit.
After you register the way to a controller, Office will download it from the given directory for all actions that have to do with it. You do not have to copy anything, you can just provide and update your vidget inside your package. Management of keys in modstore.pro already works like this, as well as output of the authors' sales statistics.
And if you are planning to use Ext JS in your vidgets, notice that by default there already are some new improved Office components, like a table with an imbedded search - you can extend them as much as you want.
AsmodExtra is suited for designing addons for MODX and already supports Office, I recommend that you use it as an example.