I’m trying to customize my Dolibarr theme and I’m trying to include something as simple as a .js file to customize certain behaviors of the menu and other parts of the theme and there is no way to get it. I have tried everything. Can someone help me on this?
To add custom JavaScript to Dolibarr, independent of future releases and updates, you can choose one of these options:
Creating a Custom Module: The best solution to keep your custom code safe from updates is to create a custom module. This module can contain your JavaScript code and will be independent of the Dolibarr core. You can develop the module from scratch or ask for assistance from experienced developers to create one tailored to your needs.
Using Hooks: Dolibarr supports the use of hooks, which are extension points where you can insert your custom code. You can create a module that uses these hooks to inject your JavaScript into the pages you want.
If you’re using a custom theme, one approach is to include your JS file by editing the theme_const.css.php
file of your theme. Even though it’s named .css.php
, it allows PHP code, so you can echo a <script>
tag there.