In this article we will see how to add additional attributes in our Dolibarr URL type. In this way we can create fields where we can enter a URL and we can click on the link to visit the página.Aunque this and what we can do with a text field, the text field can not click on the link created . The result we want to obtain is as follows: Although the change is generic to the entire application, I will base the example to use this type of field on the cards of our contacts where I will add information on their web and social networks. We will explain the steps that should be made to do so.
Create custom fields
To do this we go to the module configuration Third parties. In the third tab additional attributes We create fields that need the type Link. The data to fill each of the fields would be:
- Label: Name to be displayed on the Contact tab.
- Attribute code: Is the internal name. Always avoid using spaces and lowercase letters.
- Position: It is a numerical value of 1..n that will help us to display all the fields we have created in the order you indicate.
The other options are optional and taste of each. And this would be the result. In the record of our contacts we can already visualize the links to the website and social networks that you have that you can visit by clicking directly on the link (which with text attribute can not do).
How to implement
In order to implement the type of URL field we have to touch the code of our Dolibarr. You have to touch the files:
In the file functions.lib.php you just have to change the display size of the field so that when accessing the contact card does not leave the field and cut the url appears with an ellipsis. Change:
dol_print_url function ($ url, $ target = '_ blank', $ max = 32)
dol_print_url function ($ url, $ target = '_ blank', $ max = 60)
The extrafields.class.php file has more homework and this is where we need to create the new type and how to treat it properly to save the data and display the link format. Here you can download the file with the changes for version 3.7.1 of dolibarr:
Upgrade your Dolibarr to the latest version without risks If you like Dolibarr and would always be the last, write me and I will give personalized pricing to upgrade your Dolibarr environment without risk or compliaciones.
Keep updated your ERP / CRM Dolibarr
- Upgrade your Dolibarr without complications or risks to the latest version.
- Keep your data safe. I perform backup before performing the process.
- all information is migrated without losing anything.
- Write me and I will give personalized quote (Contact)