Menus system

= The system of Dolibarr menus = Dolibarr contains 2 systems to manage menus. One for the top menu and one for the left menu. There is no link between each other (so you can imagine to have a driver where menu entries are managed by top menu with combo lists and nothing on left menu). For explanation, we will call those 2 systems: "left menu" and "top menu".

It is possible to develop your own menu manager (for left and/or top), that will replace completely the default one. You decide how you store your menu (database like with the menu manager auguria, centralized hard coded menu entries like in the menu eldy, xml files, ...). Like you see, you can offer a menu manager with the behavior you need and the technology you want.

= Change your current menu manager = Changing your menu manager with an existing one can be done from page Home -> Menus. Take the menu manger you wnt in the list. If you enable menu manager "eldybackoffice", provided by default (Activate the left menu manager "eldybackoffice" in the same time than the top menu "eldybackoffice", both were developed to be used at the same time). All default menu managers provided by default are completely useful and offer some alternative.

And if this does not suit your need, you can still develop yours. See next chapter for that.

= Develop you own menu manager = The aim of this paper is to describe how to create a new menu system in its entirety (to replace the entire menu entries, complete upheaval of the concept of navigation). This does not relate how to add menu entries. If you just want to know how to add menu entries within an existing menu manager, when developing an extension or a new module for example, you should look page Module development instead. If you want to completely replace a system menu with your own, the easiest way is to use the menu Manager "eldy_backoffice" as an example:

To develop your own top menu
$user contains information about current user. $conf contains information about setup (activated modules, permissions, options, etc...) $langs contains information about active language.
 * 1) Copy file htdocs/core/menus/standard/eldy_backoffice.php into a file with a name like htdocs/core/menus/standard/mymenu.php
 * 2) Edit this file mymenu.php. Function showmenu of class MenuTop is the function called by Dolibarr, when generating a page, to show the top menu. You can put here the code you want, this function does not change any external vairable and must show using "print" the menu to show. So you can get menu to show from a configuration file, a database and personalized it according to environment. Environment Dolibarr is stored into 3 global variables: $user, $conf, $langs.

Example of a function showmenu into file htdocs/core/menus/standard/mymenu.php ';   }

To develop your own left menu
Principle is same than for top menu.
 * 1) You must edit function showmenu of class MenuLeft to build your left menu. If you want to show standard menu with just minor changes without redoing everything, you have to loop on content of array $menu->liste. If you want to build a menu completely different and controled only by yourself, you must, into the method showmenu, create an object $newmenu=new Menu and use methods $newmenu->add and $newmenu->add_submenu to defined list of left menu entries to show. Once this is done, you show those entries using some "print" to show content of array $newmenu->liste (that we have just defined) instead of printing content of $menu->liste.

Example of file htdocs/core/menus/standard/mymenu.php

= To force usage of your menu manager = You can force usage of your own menu manager by creating a module. For this, all you have to do is to declare the 4 following constants into the array $this->const of your module descriptor file (See page Module development). Your menu manager will be used once the module is activated.