Creating a custom module in vTiger7 using vtlib involves several steps. Here is a step-by-step guide to help you through the process:
Step 1: Set Up Your Environment
- Backup: Always take a backup of your current vTiger instance, including the database.
- Environment: Ensure you have a working vTiger 7 instance and access to the server.
Step 2: Create the Basic Structure
- Folder Structure: Navigate to
modules
directory in your vTiger installation and create a new folder for your custom module. For example, if your module is named “CustomModule”, create a folder namedCustomModule
. - Module File: Inside your
CustomModule
folder, create a file namedCustomModule.php
. This file will contain the class for your module.
Step 3: Define the Module Class
In CustomModule.php
, define your module class:
<?php
include_once 'modules/Vtiger/CRMEntity.php';
class CustomModule extends CRMEntity {
public $table_name = 'vtiger_custommodule';
public $table_index= 'custommoduleid';
// Define the mandatory table for supporting custom fields.
public $customFieldTable = Array('vtiger_custommodulecf', 'custommoduleid');
// Define the list of tables related to this module.
public $tab_name = Array('vtiger_crmentity', 'vtiger_custommodule', 'vtiger_custommodulecf');
public $tab_name_index = Array(
'vtiger_crmentity' => 'crmid',
'vtiger_custommodule' => 'custommoduleid',
'vtiger_custommodulecf'=>'custommoduleid'
);
public $list_fields = Array (
'Custom Field' => Array('custommodule', 'customfield'),
'Assigned To' => Array('crmentity','smownerid')
);
public $list_fields_name = Array (
'Custom Field' => 'customfield',
'Assigned To' => 'assigned_user_id'
);
public $list_link_field = 'customfield';
public $search_fields = Array(
'Custom Field' => Array('custommodule', 'customfield')
);
public $search_fields_name = Array (
'Custom Field' => 'customfield'
);
public $popup_fields = Array ('customfield');
public $def_basicsearch_col = 'customfield';
public $def_detailview_recname = 'customfield';
public $mandatory_fields = Array('customfield', 'assigned_user_id');
public $default_order_by = 'customfield';
public $default_sort_order='ASC';
}
?>
Step 4: Create the Installation Script
Create an installation script to register your module. Create a file named manifest.xml
in the CustomModule
directory:
<?xml version="1.0"?>
<module>
<name>CustomModule</name>
<label>Custom Module</label>
<parent>Tools</parent>
<version>1.0</version>
<type>entity</type>
<php_version>5.2</php_version>
<dependencies>
<vtiger_version>7.0</vtiger_version>
</dependencies>
<tables>
<table>
<name>vtiger_custommodule</name>
<engine>InnoDB</engine>
<fields>
<field>
<name>custommoduleid</name>
<type>int</type>
<nullable>false</nullable>
<key>PRI</key>
<extra>auto_increment</extra>
</field>
<field>
<name>customfield</name>
<type>varchar</type>
<nullable>false</nullable>
<length>255</length>
</field>
</fields>
</table>
<table>
<name>vtiger_custommodulecf</name>
<engine>InnoDB</engine>
<fields>
<field>
<name>custommoduleid</name>
<type>int</type>
<nullable>false</nullable>
<key>PRI</key>
</field>
</fields>
</table>
</tables>
</module>
Step 5: Install the Module
- Upload the Folder: Upload your
CustomModule
folder to themodules
directory of your vTiger installation. - Install via vtiger: Log in to vTiger as an administrator, go to the Module Management section, and use the “Import Module” feature to upload and install your
CustomModule
.
Step 6: Configure the Module
- Create Fields: Use the Layout Editor in vTiger to add fields to your module as needed.
- Permissions: Set permissions for roles to access the new module.
Step 7: Test Your Module
- Verify Installation: Check that the module appears in the CRM and that you can create, view, edit, and delete records.
- Debug: If there are any issues, check the
vTiger.log
andPHP error logs
for troubleshooting.
This guide provides the basic steps to create and register a custom module in vTiger 7. Depending on your specific requirements, you may need to add more customizations and functionalities.
Conclusion
All the best mentioned guides help you to easily create a custom module in Vtiger solutions with the help of vtlib. If you follow all the steps properly, then you can successfully create a custom module. For all this, it is very necessary to take backups of everything. If you want to get the best vtiger hosting solutions, then you must find out the best service providers like Infinitive Host to get budget-friendly solutions.