Control Panel Menu
A Control Panel’s Controller may contain the description of menu items that will be automatically output in all control panel sections (actions).
Here is an example of a menu in the users component settings:
Menu Description
The getBackendMenu() method returning an array of items should be defined in the controller (backend.php). Each item is represented by an array containing the following fields:
- title – item title
- url – URL
The href_to() helper function is used to form the URLs. The first parameter passes the controller name to it, the second – the action name to be referenced to. However, you should take this into account, because the URL of the control panel’s controller starts not from the root directory but from /admin/controllers/edit. There is a special property in the control panel’s controller:
$this->root_url
it contains an absolute path from the root directory. Hence, you can get the action’s URL in the following way:
href_to($this->root_url, 'action');
Menu Description Example
An example of a menu from the users component’s control panel (the code not related to the menu has been removed)
//system/controllers/users/backend.php class backendUsers extends cmsBackend{ public function getBackendMenu(){ return array( array( 'title' => LANG_USERS_CFG_FIELDS, 'url' => href_to($this->root_url, 'fields') ), array( 'title' => LANG_USERS_CFG_TABS, 'url' => href_to($this->root_url, 'tabs') ), array( 'title' => LANG_OPTIONS, 'url' => href_to($this->root_url, 'options') ), array( 'title' => LANG_PERMISSIONS, 'url' => href_to($this->root_url, 'perms', 'users') ), array( 'title' => LANG_USERS_CFG_MIGRATION, 'url' => href_to($this->root_url, 'migrations') ) ); } }
The screenshot above shows the result.