Skip to content
  1. Extras
  2. Office
  3. Logic

How it works

Office is a modular system with any number of parts (controllers). The default set includes 4:

The component has a snippet Office that calls the chosen controller and passes it all parameters you set. So settings, chunks and other options depend on the controller and are not hardcoded in the snippet.

Example: all 3 controllers on one page:

modx
[[!Office? &action=`Auth`]]
[[!Office? &action=`Profile`]]
[[!Office? &action=`miniShop2`]]

Standard controllers also have dedicated snippets with preset parameters for convenience. They all call the Office snippet internally.

Controller settings

Everything you pass to the snippet is passed to the controller; the controller decides what it needs. All standard scripts and styles are registered via system settings, like in miniShop2.

For example, the office_extjs_css system setting changes the miniShop2 cabinet look.

Old theme ([[++assets_url]]components/office/css/main/lib/xtheme-modx.old.css)

New theme ([[++assets_url]]components/office/css/main/lib/xtheme-modx.new.css)

The default theme is chosen by MODX version — 2.2 or higher.

A controller is a PHP class that extends the base Office class. Classes live in /core/components/office/controllers/; you can change any of them by copying, renaming and calling:

modx
[[!Office?
  &action=`AuthCopy`
]]

Office can also register controllers from installed extras.

Extending with other components

Other extras can register controllers by adding their path to the office_controllers_paths system setting.

Use Office::addExtension() and Office::removeExtension() — same idea as registering component models in MODX.

Example: modExtra template:

modExtra records in the manager

modExtra records on the frontend

The registered controller is called by its name, e.g.:

modx
[[!Office? &action=`modExtra`]]

You don't have to use Ext JS; this is just an example.

Everything needed to edit modExtra records on the frontend is in one commit.

After registering the controller path, Office loads it from that directory for all related actions. You don't need to copy anything; you can ship and update your widget inside your package. This is how modstore.pro key management and author sales stats work.

If you use Ext JS in your widgets, note that some Office UI components (e.g. table with search) are loaded by default and can be extended.

modExtra is for building MODX extras and already supports Office — a good reference.