I try to make a new module and got most going right but I can not get the left menu to show up at the “new” module page it keep showing up at the first page (Home) when I refresh it here is a snip of the $this->menu array:
$this->menu = array(); // List of menus to add
$r=0;
// Add here entries to declare new menus
// Example to declare a new Top Menu entry and its Left menu entry:
/* BEGIN MODULEBUILDER TOPMENU */
$this->menu[$r]=array(‘fk_menu’=>’’, // ‘’ if this is a top menu. For left menu, use ‘fk_mainmenu=xxx’ or ‘fk_mainmenu=xxx,fk_leftmenu=yyy’ where xxx is mainmenucode and yyy is a leftmenucode
‘type’=>‘top’, // This is a Top menu entry
‘titre’=>‘JOB’,
‘mainmenu’=>‘jobs’,
‘leftmenu’=>‘1’,
‘url’=>’/jobs/jobsindex.php’,
‘langs’=>‘jobs@jobs’, // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
‘position’=>1000+$r,
‘enabled’=>‘1’, // Define condition to show or hide menu entry. Use ‘$conf->mymodule->enabled’ if entry must be visible if module is enabled.
‘perms’=>‘1’, // Use ‘perms’=>’$user->rights->mymodule->level1->level2’ if you want your menu with a permission rules
‘target’=>’’,
‘user’=>0); // 0=Menu for internal users, 1=external users, 2=both
/* END MODULEBUILDER TOPMENU */
$r++ ;//1
// Example to declare a Left Menu entry into an existing Top menu entry:
// BEGIN MODULEBUILDER LEFTMENU MYOBJECT
$this->menu[$r]=array(‘fk_menu’=>‘r=0’, // ‘’ if this is a top menu. For left menu, use ‘fk_mainmenu=xxx’ or ‘fk_mainmenu=xxx,fk_leftmenu=yyy’ where xxx is mainmenucode and yyy is a leftmenucode
‘type’=>‘left’, // This is a Left menu entry
‘titre’=>‘New Job’,
‘mainmenu’=>‘jobs’,
//‘leftmenu’=>‘jobsmenu’,
‘url’=>’/jobs/jobs_card.php’,
‘langs’=>‘jobs@jobs’, // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
‘position’=>1000+$r,
‘enabled’=>’$conf->jobs->enabled’, // Define condition to show or hide menu entry. Use ‘$conf->mymodule->enabled’ if entry must be visible if module is enabled. Use ‘$leftmenu==‘system’’ to show if leftmenu system is selected.
‘perms’=>’$user->rights->jobs->create’, // Use ‘perms’=>’$user->rights->mymodule->level1->level2’ if you ant your menu with a permission rules
‘target’=>’’,
‘user’=>0); // 0=Menu for internal users, 1=external users, 2=both
$r++ ;// 2
// Example to declare a Left Menu entry into an existing Top menu entry:
// BEGIN MODULEBUILDER LEFTMENU MYOBJECT
$this->menu[$r]=array('fk_menu'=>'fk_mainmenu=jobs',
'type'=>'left', // This is a Left menu entry
'titre'=>'New Job',
'mainmenu'=>'jobs',
'leftmenu'=>'',
'url'=>'/jobs/jobs_card.php',
'langs'=>'jobs@jobs',
'position'=>100,
'enabled'=>'1',
'perms'=>'$user->rights->jobs->create',
'target'=>'',
'user'=>2);
$r++ ;
Try starting with that and if it shows then make further adjustments. Hope it helps, sorry if it doesn’t.
well my bad, that is the problem with just cut and past my first module up
The proble was I had the line:
if (! ((GETPOST(‘testmenuhider’,‘int’) || ! empty($conf->global->MAIN_TESTMENUHIDER)) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)))
{
$conf->dol_hide_leftmenu = 1; // Force hide of left menu.
}
In top of the page !! ANd I do not just it and the note is clear ; "Force hide left menu !!
so remove that line or set $conf->dol_hide_leftmenu = 0 make the menu appear.
same problem i’m getting for left menu not appearing after creation new module and have code like
$this->menu[$r++]=array( ‘fk_menu’=>‘fk_mainmenu=bedward’, // ‘’ if this is a top menu. For left menu, use ‘fk_mainmenu=xxx’ or ‘fk_mainmenu=xxx,fk_leftmenu=yyy’ where xxx is mainmenucode and yyy is a leftmenucode
‘type’=>‘left’, // This is a Left menu entry
‘titre’=>‘List MyObject’,
‘mainmenu’=>‘bedward’,
‘leftmenu’=>‘bedward_myobject_list’,
‘url’=>’/bedward/myobject_list.php’,
‘langs’=>‘bedward@bedward’, // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
‘position’=>1000+$r,
‘enabled’=>’$conf->bedward->enabled’, // Define condition to show or hide menu entry. Use ‘$conf->bedward->enabled’ if entry must be visible if module is enabled. Use ‘$leftmenu==‘system’’ to show if leftmenu system is selected.
‘perms’=>’$user->rights->bedward->create’, // Use ‘perms’=>’$user->rights->bedward->level1->level2’ if you want your menu with a permission rules
‘target’=>’’,
‘user’=>2);
The problem I found is that the menus of the first object of a module are created without increasing the position, and that violates the unique key enforced programatically (not a constraint in DB):
I am naive in Dolibarr, not sure if this is the cause of your missing left menu and I do not know where to patch this for future versions. I just fixed those lines manually and activate the module.