Replace core/tpl file with new one

Hi,

I want to add a couple of lines of code in two files:
dolibarr\htdocs\core\tpl\objectline_title.tpl.php
and
dolibarr\htdocs\core\tpl\objectline_view.tpl.php

I do not want to make changes directly in the files, because when I upgrade my dolibarr, these changes will be gone.

In these two files there are no hooks.

Is there a way to override these two files with new files, which will include my additional code?

What if you introduced hooks in those files and made a pull request? and then - if the pull request are accepted could safely add your own files that does what you want?

Hi @Passko
Are you working with module builder or on a custom module?

Hi jonbendtsen,

Could you be more specific, how exactly can I introduce hooks in those files and made a pull request.

If you can give an example , it will be very helpful to me

Regards

I created a module with module builder, but I don’t know how to proceed. Can you give me a hint how to achieve my goal?

It’s quite easy if you know what to do.
Make necessary changes in your object class file
Create inside your module folder a new folder with name tpl.
Copy in there the objectline tpl files from core and modify them.

Hi

I am a new dolibarr user and unfortunately I still do not know what to do.

This part is done.

Can you give me the path of the object class file and guide me what kind of changes I have to make?
Is the object class file the Descriptor file of module - mytestmodule/core/modules/modMytestmodule.class.php ?

Thanks in advance!

Please describe what are you trying to achieve here.
If you want to modify an existing Dolibarr object you should go with hooks as @jonbendtsen suggested

Hi,

I am using dolibarr 18.0.3.

  1. In this file dolibarr\htdocs\core\tpl\objectline_title.tpl.php I want to add this piece of code colored in yellow

  1. In this file dolibarr\htdocs\core\tpl\objectline_view.tpl.php I want to add this piece of code colored in yellow

But I do not want to add these changes directly in these two files, because after the next upgrade these changes will be lost.

In some cms system there is tool which tool can search a certain phrase in a certain file and then an additional code can be added before or after that phrase. Or replace that phrase with new one.

But in dolibarr there is no such option, that’s why I am begging for help how can I achieve this.

Hello,

Normaly, if you create your module with modulbuilder
Put 'tpl' => 1,to tell dolibarr that you are replacing template
and put the template with the same name incustom/mymodule/core/tpl/
It should be replaced

1 Like

Hi

Thank you, that did the trick.

I have one more question.
In file dolibarr\htdocs\mrp\mo_production.php
mo_production.php (61.6 KB)
I want to insert a couple of lines of code at two places.



Is there an option to replace php core files, similar to replacing tpl files?

Also, in this file there is hook execution at 3 places, but I am afraid that they do not apply to this part of the code that I want to change.

Can you help, please

Hello,

No, for core module, you have to use triggers or hooks.

Hi,

Can can you take a look the attached file in my previous post and tell me how to use the hook from this file and then I will add the code to actions_mymodule.class.php?

Hi,

As far as I can see, in your code you want to add some fields on the card.
The best way I think is to use the Tab management system : Tabs system - Dolibarr ERP CRM Wiki
You can replace a tab screen with your module tab