Hello there I'm new in vtiger. Now what i want to know is how to create costum module without using existing module designer or other same stuff. For example i want to create a custom module that will save the name and last name of a certain person. Actually I research in the internet, and I didn't find a clear tutorial on how to create a costum module specifically in vtiger 6. Do you have any good tutorial or link on how to create a costum module in vtiger 6 . Your help is greatly appreciated.
Go to modulename. php to change the class name, $table_name (6values change), $table_index (4values change). Create new file with any name. Insert the code below to add the fields and also module.
vtlib provides API to export module as a zip (package) file which can used for importing through Module Manger. (Optional: Default=test/vtlib) Directory where the zipfile output should be created. (Optional: Default=modulename-timestamp. zip) Zipfile name to use for the output file.
I found some interesting tutorial in making entity module this is the link. http://community.vtiger.com/help/vtigercrm/developers/extensions/examples/entity-module.html and it is working.
First create a new folder(module name without space
) in modules and copy files from vtlib/ModuleDir/6.0.0
file to the folder created in modules/newmodule
Change the name of ModuleName.php
with your module name(with no space) and one more ModuleName.php
file in languages\en_us
.
open the modulename.php to change the class name, $table_name , $table_index
& also available in languages\en_us
with your modulename.
Create new file with any name under your root directory. Insert the code below to add the fields and also module.
<?php
include_once 'vtlib/Vtiger/Module.php';
$Vtiger_Utils_Log = true;
$MODULENAME = 'Persons';
$moduleInstance = Vtiger_Module::getInstance($MODULENAME);
if ($moduleInstance || file_exists('modules/'.$MODULENAME)) {
echo "Module already present - choose a different name.";
} else {
$moduleInstance = new Vtiger_Module();
$moduleInstance->name = $MODULENAME;
$moduleInstance->parent= 'Tools';
$moduleInstance->save();
// Schema Setup
$moduleInstance->initTables();
// Field Setup
$block = new Vtiger_Block();
$block->label = 'LBL_'. strtoupper($moduleInstance->name) . '_INFORMATION';
$moduleInstance->addBlock($block);
$blockcf = new Vtiger_Block();
$blockcf->label = 'LBL_CUSTOM_INFORMATION';
$moduleInstance->addBlock($blockcf);
$field1 = new Vtiger_Field();
$field1->name = 'lastname';
$field1->label= 'Last Name';
$field1->uitype= 2;
$field1->column = $field1->name;
$field1->columntype = 'VARCHAR(255)';
$field1->typeofdata = 'V~M';
$block->addField($field1);
$moduleInstance->setEntityIdentifier($field1);
$field2 = new Vtiger_Field();
$field2->name = 'firstname';
$field2->label= 'First Name';
$field2->uitype= 1;
$field2->column = $field2->name;
$field2->columntype = 'VARCHAR(255)';
$field2->typeofdata = 'V~M';
$block->addField($field2);
// Recommended common fields every Entity module should have (linked to core table)
$mfield1 = new Vtiger_Field();
$mfield1->name = 'assigned_user_id';
$mfield1->label = 'Assigned To';
$mfield1->table = 'vtiger_crmentity';
$mfield1->column = 'smownerid';
$mfield1->uitype = 53;
$mfield1->typeofdata = 'V~M';
$block->addField($mfield1);
$mfield2 = new Vtiger_Field();
$mfield2->name = 'CreatedTime';
$mfield2->label= 'Created Time';
$mfield2->table = 'vtiger_crmentity';
$mfield2->column = 'createdtime';
$mfield2->uitype = 70;
$mfield2->typeofdata = 'T~O';
$mfield2->displaytype= 2;
$block->addField($mfield2);
$mfield3 = new Vtiger_Field();
$mfield3->name = 'ModifiedTime';
$mfield3->label= 'Modified Time';
$mfield3->table = 'vtiger_crmentity';
$mfield3->column = 'modifiedtime';
$mfield3->uitype = 70;
$mfield3->typeofdata = 'T~O';
$mfield3->displaytype= 2;
$block->addField($mfield3);
// Filter Setup
$filter1 = new Vtiger_Filter();
$filter1->name = 'All';
$filter1->isdefault = true;
$moduleInstance->addFilter($filter1);
$filter1->addField($field1)->addField($field2, 1)->addField($field3, 2)->addField($mfield1, 3);
// Sharing Access Setup
$moduleInstance->setDefaultSharing();
// Webservice Setup
$moduleInstance->initWebservice();
mkdir('modules/'.$MODULENAME);
echo "OK\n";
}
?>
There's a simple Console tool for creating new custom modules:
open the cmd prompt, go to the vtlib/tools folder and execute the Console.php file:
>cd C:\{$YourPathToVtiger}\apache\htdocs\vtigerCRM\vtlib\tools
>php -f Console.php
Type '1' for Creating a new module and set "Module name" and "Entity field" (the Entity field is the field that will be shown in bold at the top of the window, when you open an instance of that module).
Now the new module is created and installed, and you can easily customize it (adding new fields, workflows and whatever) from the vTiger GUI.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With