How to manually set the menu
The ATiM2 menus are built with the /app/controllers/components/menus.php component and the /app/views/helpers/shell.php helper. By default, the component is automatically called by the application in the /app/app_controller.php beforeFilter() function, and the helper to called by the /app/views/layouts/default.ctp layout.
Menu data is broken up in two parts, both defined by Controller->set() function for use in the helper:
1. The variable atim_menu is populated by the component's $this->Menus->get() action. By default, the app_controller's beforeFilter() will use the current plugin-controller-action combination to look up the "at" menu item.
2. The variable atim_menu_variables is an array of variables that above results will use to replace string placeholders. By default, the app_controller's beforeFilter() will use an empty array.
The component's $this->Menus->get() action uses a provided URL string (expected to be within the application), and finds the first row in the menus datatable that has a LIKE match in the use_link field. For example, the SQL might look like...
WHERE Menus.use_link LIKE "/plugin/controller/action%"
And it find a url that looks like this...
/plugin/controller/action/%%Model.field%%/%%Model.field%%
Once it has that one row, the menu item the user is currently "at", it finds all it's siblings, and then uses the parent_id field to find it's parent. This process is repeated all the way up the line until it reaches a parent_id with no parents. Therefore, it's important that ALL menu items fit into the overall menu "tree" somewhere... as orphaned menu items actually cause the menu component to return incorrect or blank results.
The %%Model.field%% strings in the URL are placeholders which get switched out with keys=>values provided in atim_menu_variables variable, which would look something like this:
array( 'Model.field'=>'value', 'Model.field'=>'value', 'Model.field'=>'value' );
In most cases, the app_controller's beforeFilter() will be able to correctly guess which URL to use for the current "at" menu item, but in some cases, the URL and the actual plugin-controller-action will not match up. In this case, the plugin developer need only call the same $this->Menus->get() function in their controller, passing the desired URL as a string parameter; this will override the app_controller's default choice as long as the $this->set the variable name the same.
In almost all cases, the developer will have to override the app_controller's atim_menu_variables empty array variable. Like the above, declaring it will override the app_controller's default setting.