For the things that build it, you might want to see:
This file creates the structure of the layout, as well as loading the topbar and trees.
- manager/templates/default/ui/modtopmenu.class.js (to be renamed eventually to modx.topmenu.js)
This loads the Top Menu. However, most everything is loaded from JSON data, which merits explanation. The PHP file that pulls it is here:
Note that it is grabbing "modMenu" objects. These objects are fields stored in the DB (modx_menus), which has the following fields:
- id - The ID of the menu object
- parent - The menus are heirarchical, so each menu can have a parent.
- action - The modAction to redirect to when clicked. Note that this is an object. This is explained below.
- text - The i18n string index to the $modx->lexicon ($_lang) string that will display the menu item text
- icon - The URL to the icon to use. Optional.
- menuindex - The order of the menu in its parent. Menus can be reordered.
- params - Any GET params that you want to pass when clicking on the menu.
- handler - Any JS you want to run before the menu loads the page (an onclick event).
Note that these menus (and actions) can be managed via the Tools -> Actions page. The Top Menu can be rearranged, modified, etc, all from the tree on that page.
modActions are abstract representations of controllers (manager/controllers/). The reason they are in the database is to allow connection between them and the top menu, as well as other menus in MODx. They also will allow 3rd party components (snippets/plugins/etc) to create their own submenus for MODx, and customize the manager without modifying core code. Their fields are:
- id - the action’s ID
- context_key - The context in which the action is in.
- parent - modActions can have parents as well, keeping them organized.
- controller - The actual file path (starting from manager/controllers, and will be postfixed with .php (will also first search for "NAME/index.php").
- haslayout - Whether or not to load the header/footer for the page
- assets - Any other files related to the controller (not currently in use in 097)
Hope that helps, Susan.