# Add custom button

**URL:** <https://www.dolibarr.org/forum/t/add-custom-button/24091>\
**Category:** Developing for Dolibarr\
**Created:** [August 1, 2023, 12:58pm UTC](https://www.dolibarr.org/forum/t/add-custom-button/24091 "2023-08-01T12:58:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![RPBTworker](https://www.dolibarr.org/forum/letter_avatar_proxy/v4/letter/r/3d9bf3/32.png) [@RPBTworker](https://www.dolibarr.org/forum/u/RPBTworker)\
**Post date:** [August 1, 2023, 12:58pm UTC](https://www.dolibarr.org/forum/t/add-custom-button/24091/1 "2023-08-01T12:58:48Z")

</div>

Hello there,  
I currently try to add a button to the “mocard.php” to create a label with a QR-code for the site of the MO I am currently on. To add it into the source code was not that hard (without functionality), but I want to try it via a modul.  
Problem is I can’t seem to figure out how add the button via a hook. The [wiki site](https://wiki.dolibarr.org/index.php?title=Hooks_system) didn’t give me a clear enough idea to accomplish that.  
Do you guys have to an idea where I can find inspiration to accomplish it, so the button is added in the “mocard.php”?  
Hopefully you can help me in finding a tutorial / modul to broaden my understanding.

Kind regards,  
RPBTworker

---

<div class="post-metadata">

**Author:** ![RPBTworker](https://www.dolibarr.org/forum/letter_avatar_proxy/v4/letter/r/3d9bf3/32.png) [@RPBTworker](https://www.dolibarr.org/forum/u/RPBTworker)\
**Post date:** [August 9, 2023, 12:11pm UTC](https://www.dolibarr.org/forum/t/add-custom-button/24091/2 "2023-08-09T12:11:20Z")

</div>

I found out how I add a button, even though the functionality part is not working yet.  
Had to look in the source code for the executeHook({hookName}). In my example it was the hookName “addMoreActionsButtons”.  
Afterwards I just to had to add the following code for the if-clause: `print '<a class="butAction" href="/custom/molabelmaker/class/generate_output.php">Create Label</a>'`  
Still struggling with the href, because when pressing this “Link” I get different errors, because I am no PHP pro.

---

<div class="post-metadata">

**Author:** ![RPBTworker](https://www.dolibarr.org/forum/letter_avatar_proxy/v4/letter/r/3d9bf3/32.png) [@RPBTworker](https://www.dolibarr.org/forum/u/RPBTworker)\
**Post date:** [August 15, 2023, 8:53am UTC](https://www.dolibarr.org/forum/t/add-custom-button/24091/3 "2023-08-15T08:53:46Z")

</div>

Ok, right now I use the addMoreActionsButtons method in my “`actions_molabelmaker.class.php`” to add a “Link” that sends my to another class.php file were I try to access my “`labelPrint.class.php`”.  
In the lablPrint file I want to create, design and output my label in a format that befits our label printer. Problem is now: the dolibarr functions and constants are not recognized!  
I mean stuff like dol\_include\_once(…) or pdf\_getInstance(…). I don’t know why or how to fix that. Other modules from the dolistore, just use them or I can’t figure out what they made different so the class.php file can use dolibarr code without errors.  
Would love advice, if anyone has some.  
Pics of my code currently, if wanted:  
`actions_molabelmaker.class.php`

 ![grafik](https://www.dolibarr.org/forum/uploads/dolibarrorg/original/2X/7/76b408e564724fb24377129c221cdf9763647628.png)

`labelPrinter.class.php`

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

`genrate_output..class.php`

 ![grafik](https://www.dolibarr.org/forum/uploads/dolibarrorg/original/2X/c/c401ada9cbc98b3657c0ba00060e1f692a88e0d7.png)
