Menus system: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
Line 19: Line 19:


== To develop your own '''top menu''' ==
== To develop your own '''top menu''' ==
# Copy file htdocs/includes/menus/standard/eldy_backoffice.php into a file with a name like htdocs/includes/menus/standard/mymenu.php
# Copy file htdocs/core/menus/standard/eldy_backoffice.php into a file with a name like htdocs/core/menus/standard/mymenu.php
# 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.
# 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.
  $user contains information about current user.
  $user contains information about current user.
Line 25: Line 25:
  $langs contains information about active language.
  $langs contains information about active language.


Example of a function showmenu() into file htdocs/includes/menus/standard/mymenu.php
Example of a function showmenu() into file htdocs/core/menus/standard/mymenu.php
<source lang="php">
<source lang="php">
     function showmenu()
     function showmenu()
Line 47: Line 47:
# 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.
# 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/includes/menus/standard/mymenu.php
Example of file htdocs/core/menus/standard/mymenu.php
<source lang="php">
<source lang="php">
     function showmenu()
     function showmenu()

Navigation menu