User Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
en:devel:createvtlibmodule [2017/11/07 00:30]
joebordes
en:devel:createvtlibmodule [2020/04/15 22:38] (current)
joebordes
Line 5: Line 5:
 This is the process I follow. This is the process I follow.
  
-**Module Name**: this name will serve as the start for translation files and also as the internal name of the module. As with any name it should be significant and  identify what the module represents but it also must be unique in your coreBOS ​ install. I recommend prefixing a company identifier. The internal name must be a valid PHP identifier. For example+**Module Name**: this name will serve as the start for translation files and also as the internal name of the module. As with any name it should be significant and identify what the module represents but it also must be unique in your coreBOS install. I recommend prefixing a company identifier. The internal name must be a valid PHP identifier. For example
  
 ^Name: | Just Log It | ^Name: | Just Log It |
 ^Internal Name: | cbJustLogIt | ^Internal Name: | cbJustLogIt |
  
-**Repository**:​ create a repository to manage your module. For example, ​ https://GitHub.com/​tsolucio/​cbJustLogIt+**Repository**:​ create a repository to manage your module. For example, ​ https://github.com/​tsolucio/​cbJustLogIt
  
-Now we have to **define the fields**, their validations and their layout. I use a template that defines the block name followed by each field definition in the order I want them to appear on screen. In this layout I also indicate which field will be the record link identifier and any special functionality I need the fields to have. This looks like this+Now we have to **define the fields**, their validations and their layout. I use a template that defines the block name followed by each field definition in the order I want them to appear on the screen. In this layoutI also indicate which field will be the record link identifier and any special functionality I need the fields to have. This looks like this
  
  
Line 32: Line 32:
 | rel_module | 1 | rel_module | Related Module | 2 | V~O | save the setype of the module rel_id if set in save_module | | rel_module | 1 | rel_module | Related Module | 2 | V~O | save the setype of the module rel_id if set in save_module |
 | | | | | | | | | | | | | | | |
-| donefrom | 1 | donefrom' ​| Done From | 2 | V~O | save $_SERVER['​REMOTE_ADDR'​] in save_module |+| donefrom | 1 | donefrom | Done From | 2 | V~O | save $_SERVER['​REMOTE_ADDR'​] in save_module |
 | | | | | | | | | | | | | | | |
 ^ Block: Custom information ^^^^^^^ ^ Block: Custom information ^^^^^^^
Line 43: Line 43:
   * how I mark the justlogitno field as the link field for the module, ​   * how I mark the justlogitno field as the link field for the module, ​
   * how I group the fields two by two to indicate each row   * how I group the fields two by two to indicate each row
-  * how I add a comment on how tpand where to fill in the two displaytype 2 fields+  * how I add a comment on how and where to fill in the two displaytype 2 fields
   * how I accommodate space for the default fields   * how I accommodate space for the default fields
   * how I specify the modules supported by the uitype 10 capture field   * how I specify the modules supported by the uitype 10 capture field
 +  * **ALL** field and column names **MUST** be in lower case
  
 Next up are the **list view fields**. We have to choose from the fields above which ones will appear on the "​All"​ filter, which ones appear in the popup when we try to select a record from this module and also which fields appear on any related list this module may be related to. I simply indicate them like this Next up are the **list view fields**. We have to choose from the fields above which ones will appear on the "​All"​ filter, which ones appear in the popup when we try to select a record from this module and also which fields appear on any related list this module may be related to. I simply indicate them like this
  
-^ List View Fields: | justlogitno,​ fecha, hora, eventovalue, Assigned To | +^ List View Fields: | justlogitno,​ fecha, hora, operationmoreinfo, Assigned To | 
-^ Related List Fields: | justlogitno,​ fecha, hora, eventovalue, Assigned To | +^ Related List Fields: | justlogitno,​ fecha, hora, operationmoreinfo, Assigned To | 
-^ Popup Search Fields: | justlogitno,​ fecha, hora, eventovalue, Assigned To |+^ Popup Search Fields: | justlogitno,​ fecha, hora, operationmoreinfo, Assigned To |
  
 Now we must **define the relations** this module has with other modules in the system. These will be indicated by the uitype 10 fields above and any many to many relations the module may have Now we must **define the relations** this module has with other modules in the system. These will be indicated by the uitype 10 fields above and any many to many relations the module may have
Line 60: Line 61:
 | Documents | get_attachments | | Documents | get_attachments |
  
-Next we must **define the initial sharing privileges** and the ditribution ​license of the module.+Nextwe must **define the initial sharing privileges** and the distribution ​license of the module.
  
 ^ Module: | public | ^ Module: | public |
Line 66: Line 67:
  
  
-Finally we must **specify any additional functionality**. This is where we will explain cron jobs, event handlers and any special widgets or operations the module ​must have.+Finallywe must **specify any additional functionality**. This is where we will explain cron jobs, event handlers and any special widgets or operations the module ​will have.
  
 Reached this point we have a clear idea of everything we need to create our module and we can start coding. Reached this point we have a clear idea of everything we need to create our module and we can start coding.
 +
 +{{ :​en:​devel:​moduletemplate.zip |You can download a text template here}}
  
 The steps are The steps are
  
-**1.-** copy the vtlib/​ModuleDir directory to the "​modules"​ directory renaming it to the internal name of your module+**1.-** copy the [[https://​github.com/​tsolucio/​corebos/​tree/​master/​vtlib/​ModuleDir|vtlib/​ModuleDir directory]] to the "​modules"​ directory renaming it to the internal name of your module
  
 <​code>​cp -a vtlib/​ModuleDir modules/​cbJustLogIt</​code>​ <​code>​cp -a vtlib/​ModuleDir modules/​cbJustLogIt</​code>​
Line 94: Line 97:
 **3.4.-** Add the SQL to create the main table. **3.4.-** Add the SQL to create the main table.
  
-**3.4.1.-** This table must be the name of your module in lower case prefixed with "​vtiger_"​.+**3.4.1.-** This table must be the name of your module in **lowercase** ​prefixed with "​vtiger_"​.
  
-**3.4.2.-** It must contain the internal primary key which is the name of your module in lower case followed by "​id"​+**3.4.2.-** It must contain the internal primary key which is the name of your module in **lowercase** ​followed by "​id"​
  
 **3.4.3.-** Add a field for all the fields in your module except the common _crmentity fields **3.4.3.-** Add a field for all the fields in your module except the common _crmentity fields
Line 104: Line 107:
 **3.5.-** Change the name of the custom field table **3.5.-** Change the name of the custom field table
  
-**3.6.-** Now for each block and field fill in the fields XML accordingly. There are a lot of exsting ​manifest.xml files in the application for you to study.+**3.6.-** Now for each block and field fill in the fields XML accordingly. There are a lot of existing ​manifest.xml files in the application for you to study.
  
 **3.7.-** Fill in the All filter fields **3.7.-** Fill in the All filter fields
  
-**3.8.-** Fill in the sharing access, default actions, related ​ lists and other special settings+**3.8.-** Fill in the sharing access, default actions, related listsand other special settings
  
-**4.-** edit the main module file and change ​+**4.-** ​Each module has a main file that defines its class. This file was copied in step 1 and renamed in step 2. So we now have a file called: 
 + 
 +<​code>​ 
 +modules/​cbJustLogIt/​cbJustLogIt.php 
 +</​code>​ 
 + 
 +edit this main module file and change
  
 **4.1.-** the module class name **4.1.-** the module class name
  
-**4.2.-** replace **MODULE_NAME_LOWERCASE** with the lowercase internal name of your module+**4.2.-** replace **MODULE_NAME_LOWERCASE** with the **lowercase** internal name of your module
  
 **4.3.-** replace **MODULE_REFERENCE_FIELD** with the name of your modules'​ reference field **4.3.-** replace **MODULE_REFERENCE_FIELD** with the name of your modules'​ reference field
Line 123: Line 132:
  
 <code PHP>​$this->​setModuleSeqNumber('​configure',​ $modulename,​ $modulename.'​-',​ '​0000001'​);</​code>​ <code PHP>​$this->​setModuleSeqNumber('​configure',​ $modulename,​ $modulename.'​-',​ '​0000001'​);</​code>​
 +
 +**5.-** Translate
 +
 +**5.1.-** Get the set of labels used and copy them to the en_us.lang.php file
 +
 +<​code>​grep -i label manifest.xml</​code>​
 +
 +Once he en_us.lang.php is translated copy it to any other language file and translate accordingly.
  
  
Line 129: Line 146:
 Now you are ready to install and test. Use the build/​HelperScripts/​installmodule.php script. Now you are ready to install and test. Use the build/​HelperScripts/​installmodule.php script.
  
-Before installing I like to make a dump of the database so I can easily recover if made a mistake and try again. Normally the errors appear in the manifest field definitions,​ typical copy paste errors.+Before installing I like to make a dump of the database so I can easily recover if made a mistake and try again. Normally the errors appear in the manifest field definitions,​ typical copy-paste errors.
  
-In order to be able to send this module to any coreBOS you have to setup a specific structure.+In order to be able to send this module to any coreBOSyou have to set up a specific structure.
  
 <WRAP center round info 70%> <WRAP center round info 70%>
Line 140: Line 157:
 The structure looks like this: The structure looks like this:
  
 +<​code>​
 +manifest.xml
 +modules/
 +  ModuleName/
 +   <​Module Related Files>
 +   ​language/​
 +    en_us.lang.php
 +    <Other language Files>
 +templates/
 +  <Smarty templates of the Module>
 +</​code>​
  
 The manifest in the top level is a copy of the one inside the modules directory. The manifest in the top level is a copy of the one inside the modules directory.
Line 146: Line 174:
  
 <WRAP center round info 70%> <WRAP center round info 70%>
-If your repository is publically ​avaialble ​on github ​you can have your users install it directly from the github ​URL+If your repository is publically ​available ​on GitHub ​you can have your users install it directly from the GitHub ​URL
 </​WRAP>​ </​WRAP>​
  
Line 152: Line 180:
  
  
- +<WRAP center round info 60%> 
 +This is just the basic skeleton and functionality of a module. There are a lot of things that you can customize, so look for help on [[https://​gitter.im/​corebos/​discuss|Gitter]] or the [[http://​discussions.corebos.org/​|forum]] 
 +</​WRAP>​