The MVC system uses a controller map to specify which controllers are available to the site. This is unique to each site and must always be created. It cannot be inherited from other sites.
The controller map differs from the other config files listed so far by being more like the site map. It features only a few tags, namely: controllers and controller. A controller can contain a controllers group and the file itself is contained in a controllers tag pair.
The contents of this file will directly mirror what will be available to the site. It can be auto-generated using the admin site if the various controllers exist within the controllers database.
A very basic controller map may look like the following:
<controllers>
<controller name="home" description="Home Page" />
<controller name="static" description="A Static Page" />
</controllers>
This config allows for a single controller called "home" and is the default configuration of the base controllerMap.xml file. Each controller "name" relates to a class prefix within the controllers folder of the site. The controller can exist in any site within the site hierarchy.
An example is the static page controller. This controller can be found in:
/websites/base/controllers/static
However it can be accessed by any site just by including:
< controller name="static" / >
In the site controllerMap file. The MVC system will look down through the parent site config options until it reaches the base site (all sites should ultimately resolve to the base site).
A controller can take the following parameters as attributes on the controller tag:
| Attribute | Description |
|---|---|
| name | The controller class prefix, usually relates to a nameContorller .class.php file |
| description |
A friendly text description for the controller, if not set, the controller name is split apart and each word is capitalised e.g. siteEditor -> Site Editor |
| path |
The full path to the file containing the controller if it is not within the controller map path e.g. a controller userAdmin is located in controlPanel/userManager/ by default the system will look for /controlPanel/userManager/userAdminController.class.php within the controllers folder. If it is not located here, the path must be e.g.: set /users/userAdminController.class.php |
Posted by: Dave Redfern (Writer), in Documentation on 13 Apr 2008 @ 11:43
Tags: configuration, controller, controllermap, systemconfig,
Contents:
This
work is licenced under a
Creative Commons Licence.