Create a PDF document template: Difference between revisions

Jump to navigation Jump to search
Tag: 2017 source edit
Line 65: Line 65:


=Create a new template=
=Create a new template=
==For an existing module==
==For an existing core module==
Do not directly modify an existing template. Copy the file of the template used as example into a new name in same directory and edit it to change content.
Do not directly modify an existing template.  
For this example, we will call our new template 'mycompanyblue', based on the existing template 'cyan':
Although it is possible to copy the file of the template used as example into a new name in same directory and edit it to change content it is strongly recommended not to modify any core file or structure(If you want to fix something use the project Github page to propose your changes).


*Copy and paste file pdf_cyan.modules.php
Instead use the the Module Builder [[Module development]] available from v12.0 to create your own module even for just a new template.
 
For this example, we will call our new module 'mymodule' and our template 'mycompanyblue', based on the existing template 'cyan':
 
 
*Copy and paste file pdf_cyan.modules.php into custom/mymodule/core/modules/propale/doc
*Rename the copy as pdf_mycompanyblue.modules.php
*Rename the copy as pdf_mycompanyblue.modules.php
*Edit and make the following changes in the code:
*Edit the file and make the following changes in the code:


#Rename 'Class pdf_cyan { ' to 'Class pdf_mycompanyblue { '
#'Class pdf_cyan' to 'Class pdf_mycompanyblue'
#Rename constant $this->name to match your new template name. For example for 'cyan' template, change line '$this->name = "cyan";' to '$this->name = "mycompanyblue";'.
#'$this->name = "cyan";' to '$this->name = "mycompanyblue";'.
#Save file. Now the template will be available in the list of models in Dolibarr.
#'$this->description = $langs->trans('DocModelCyanDescription');' to '$this->description = $langs->trans('DocModelCyanDescription');'.
#Save file.  
Now the template will be available in the list of models in Dolibarr.


Test this model (see previous section) before going further.
Test this model (see previous section) before going further.
83

edits

Navigation menu