# Need explanation of the usage of fk\_mainmenu, fk\_leftmenu, mainmenu and leftmenu in Module Building

**URL:** <https://www.dolibarr.org/forum/t/need-explanation-of-the-usage-of-fk-mainmenu-fk-leftmenu-mainmenu-and-leftmenu-in-module-building/25524>\
**Category:** Developing for Dolibarr\
**Tags:** v17, Question, Help, Linux\
**Created:** [July 4, 2024, 9:08am UTC](https://www.dolibarr.org/forum/t/need-explanation-of-the-usage-of-fk-mainmenu-fk-leftmenu-mainmenu-and-leftmenu-in-module-building/25524 "2024-07-04T09:08:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tiziano.pedrazzoli](https://www.dolibarr.org/forum/letter_avatar_proxy/v4/letter/t/3d9bf3/32.png) [@tiziano.pedrazzoli](https://www.dolibarr.org/forum/u/tiziano.pedrazzoli)\
**Post date:** [July 4, 2024, 9:08am UTC](https://www.dolibarr.org/forum/t/need-explanation-of-the-usage-of-fk-mainmenu-fk-leftmenu-mainmenu-and-leftmenu-in-module-building/25524/1 "2024-07-04T09:08:57Z")

</div>

as per title, I am building a module and need a more thorough explanation of how `mainmenu`, `leftmenu`, `fk_menu` work. In the [documentation](https://wiki.dolibarr.org/index.php?title=Module_development#Define_your_entries_in_menu_.28optional.29) (the only one I could find) and directly in the code comments I found only this:

> For left menu, use ‘fk\_mainmenu=xxx’ or ‘fk\_mainmenu=xxx,fk\_leftmenu=yyy’ where xxx is mainmenucode and yyy is a leftmenucode.

Written this way, it is not clear what they do; it is not explained what `mainmenucode` and `leftmenucode` are or where they can be found.  
It is not explained what `mainmenu` and `leftmenu` are for, it just seems like repetition.

Need a detailed explanation of how to create a side menu, how to create dividers, subheadings

Thanks

---

<div class="post-metadata">

**Author:** ![caos30](https://www.dolibarr.org/forum/user_avatar/www.dolibarr.org/caos30/32/6733_2.png) [@caos30](https://www.dolibarr.org/forum/u/caos30)\
**Post date:** [July 5, 2024, 2:05am UTC](https://www.dolibarr.org/forum/t/need-explanation-of-the-usage-of-fk-mainmenu-fk-leftmenu-mainmenu-and-leftmenu-in-module-building/25524/2 "2024-07-05T02:05:06Z")

</div>

Hello, i think like you: the official documentation is really not enough. But i can share with you (and future people searching about this) how i get it run 🤗

For example, in my module Ticket Plus to get this on the LEFT menu of the “Ticket” native module:

- a “title” element with icon: “ **HelpDesk** ”
- a “link” element: “ **Public Portal** ”
- a “link” element, under “Knowledge base” group (native module): “ **Searches with AI** ”

![image](https://www.dolibarr.org/forum/uploads/dolibarrorg/original/2X/a/a3c1a06d32e5d0f55134b336408df48a582f8b85.png)

i have defined this code on the file /custom/ticketplus/core/modules/modTicketplus.class.php

```auto
$this->menu[$r]=array(
	'fk_menu'=>'fk_mainmenu=ticket',
	'type'=>'left',
	'titre'=>'HelpDesk',
	'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth"'),
	'mainmenu'=>'ticket',
	'leftmenu'=>'ticketplus',
	'url'=>'',
	'langs'=>'ticketplus@ticketplus',
	'position'=>20,
	'enabled'=>'1',
	'perms'=>'',
	'target'=>'',
	'user'=>0);
$r++;
$this->menu[$r]=array(
	'fk_menu'=>'fk_mainmenu=ticket,fk_leftmenu=ticketplus',
	'type'=>'left', // This is a Left menu entry
	'titre'=>'ticketplusLeftMenu1',
	'mainmenu'=>'ticket',
	'leftmenu'=>'',
	'url'=> $url,
	'langs'=>'ticketplus@ticketplus',
	'position'=>21,
	'enabled'=>'1',
	'perms'=>'',
	'target'=>'',
	'user'=>0);

$r++;
$this->menu[$r]=array(
	'fk_menu'=>'fk_mainmenu=ticket,fk_leftmenu=knowledgemanagement_knowledgerecord',
	'type'=>'left',
	'titre'=>'ticketplusLeftMenu2',
	'mainmenu'=>'ticket',
	'leftmenu'=>'knowledgemanagement_list',
	'url'=> '/ticketplus/article_search_list.php',
	'langs'=>'ticketplus@ticketplus',
	'position'=>113,
	'enabled'=>'$conf->knowledgemanagement->enabled',
	'perms'=>'$user->rights->knowledgemanagement->knowledgerecord->read',
	'target'=>'',
	'user'=>0);

```

Conclusions to be extracted:

- `'mainmenu'=>'ticket'` is used in all 3 elements to indicate tha they must appear when `mainmenu=ticket` appears in the URL
- `'type'=>'left'` is used in all 3 elements to indicate that we want to render it on the left vertical panel, no at the top menu panel
- the attribute `leftmenu` is not very clear to me. I think that i can define here a non-existing value, and then it will serve as “anchor” where to hang/group other items, for example when the first element to use it is of type “title” (= no url defined). Or you can also define here an existing `leftmenu` (like ‘leftmenu’=\>‘knowledgemanagement\_list’) to make define this element as a child of an existing one.
- once setted the previous points, then you must build the `fk_menu` attribute, as you said, something redundant: combining `mainmenu` and `leftmenu` values.
- regarding to TEXT TRANSLATIONS, take in account that if you are using your language module files then you must set this attribute: `'langs'=>'ticketplus@ticketplus'` (where “ticketplus” must be the main directory name of your module) and set this for element text: `'titre'=>'ticketplusLeftMenu1'` (where this is one of the text tags defined on your language files)

I hope this put more light on what to get it work in your case!

Cheers,  
Sergi

---

<div class="post-metadata">

**Author:** ![tiziano.pedrazzoli](https://www.dolibarr.org/forum/letter_avatar_proxy/v4/letter/t/3d9bf3/32.png) [@tiziano.pedrazzoli](https://www.dolibarr.org/forum/u/tiziano.pedrazzoli)\
**Post date:** [July 5, 2024, 9:18am UTC](https://www.dolibarr.org/forum/t/need-explanation-of-the-usage-of-fk-mainmenu-fk-leftmenu-mainmenu-and-leftmenu-in-module-building/25524/3 "2024-07-05T09:18:53Z")

</div>

> [@caos30](#):
>
> Sergi

thank you for your response Sergi,  
I will use your information to improve my side menu and if I find out other things I will put them in a comment.  
It is a pity that the documentation sins a lot in some places, dolibarr is a great software, if it was also easily maintainable we would all be happier

---

<div class="post-metadata">

**Author:** ![dobal](https://www.dolibarr.org/forum/letter_avatar_proxy/v4/letter/d/e79b87/32.png) [@dobal](https://www.dolibarr.org/forum/u/dobal)\
**Post date:** [July 5, 2024, 9:36am UTC](https://www.dolibarr.org/forum/t/need-explanation-of-the-usage-of-fk-mainmenu-fk-leftmenu-mainmenu-and-leftmenu-in-module-building/25524/4 "2024-07-05T09:36:06Z")

</div>

Hi all  
This is a community effort and ideally everyone should share knowledge.  
If you can improve the documentation instead of comments.  
Thanks

---

<div class="post-metadata">

**Author:** ![tiziano.pedrazzoli](https://www.dolibarr.org/forum/letter_avatar_proxy/v4/letter/t/3d9bf3/32.png) [@tiziano.pedrazzoli](https://www.dolibarr.org/forum/u/tiziano.pedrazzoli)\
**Post date:** [July 5, 2024, 9:45am UTC](https://www.dolibarr.org/forum/t/need-explanation-of-the-usage-of-fk-mainmenu-fk-leftmenu-mainmenu-and-leftmenu-in-module-building/25524/5 "2024-07-05T09:45:21Z")

</div>

I will add a comment to make sure that if someone ended up in this thread they would still have the information they are looking for.  
If I can retrieve enough information and make sure it is 100% correct I will bother to update the documentation, assuming I have the ability to do so.

Of course, no one could fix the documentation better than the person who created that portion of the code
