Menu

Step8CreatingModuleFiles

Federico

Step 8: Creating module files (Frontend)

Each new module should have a directory under modules/folder. To help speed up the module code creation, vtlib comes bundled with skeleton module structure based on the 'InstalledBase' module. This code is include in vtlib/ModuleDir folder which can be used as a template for new module that is created. It contains source files that needs to be changed as explained below.

NOTE: ModuleDir has sub-directories specific to vteddy version, please make sure to use the right one.

  1. Copy ModuleDir/<target_vtiger_version> contents to newly created modules/<newmodulename> folder.</newmodulename></target_vtiger_version>
  2. Rename <newmodulename>/ModuleFile.php as <newmodulename>/<newmodulename>.php (as noted in the table below)</newmodulename></newmodulename></newmodulename>
  3. Rename <newmodulename>/ModuleFileAjax.php as <newmodulename>/<newmodulename>Ajax.php</newmodulename></newmodulename></newmodulename>
  4. Rename <newmodulename>/ModuleFile.js to <newmodulename>/<newmodulename>.js</newmodulename></newmodulename></newmodulename>
  5. Edit <newmodulename>/<newmodulename>.php
    a. Rename Class ModuleClass to <newmodulename>
    b. Update $table_name and $table_index (Module table name and table index column)
    c. Update $groupTable
    d. Update $tab_name, $tab_name_index
    e. Update $list_fields, $list_fields_name, $sortby_fields, $list_link_field
    f. Update $detailview_links
    g. Update $default_order_by, $default_sort_order
    h. Update $required_fields
    i. Update $customFieldTable
    j. Rename function ModuleClass to function <newmodulename> (This is the Constructor Class)</newmodulename></newmodulename></newmodulename></newmodulename>

NOTE: Other files under modules/<newmodulename> need not be changed.</newmodulename>

Example ModuleDir Purpose File under Payslip
ModuleFile.php Module class definition file. Payslip.php
ModuleFileAjax.php Base file for ajax actions used under Listview etc... PayslipAjax.php
ModuleFile.js Module specific javascript function can be written here Payslip.js
CallRelatedList.php More Information Detail view handler CallRelatedList.php
DetailViewAjax.php Detail view ajax edit handler DetailViewAjax.php
EditView.php Edit view handler EditView.php
Save.php Module record save handler Save.php