Recently, I had to create a new module for vtigerCRM for my client in current working place. I did search in many places including the official vtiger sites, but couldn’t find a better documentation for my purpose. The latest vtiger version at that time was 5.0.3. Because I had some experience doing lots of core modifications for this system, I did decide to read the source code and find how to add a new module. Finally, I could create a new module and started the project. So, I thought it will be a good thing to write some thing on my blog about this topic, so that others who want to do this thing can read. Given below is a brief description about how to create a new module for vtiger CRM 5.0.3. Source code of this example module is also available to Download.
Create a directory called “newModule” inside your vtiger modules directory, or any other name that you prefer. Now, module index file should be created. Create a new file called “index.php” inside the “newModule” directory and insert following code.
And next the “ListView.php” file should be created. This name “ListView” is not compulsory. In fact, you can include any script that you prefer to run when the users are entering to the module. The content of the “ListView.php” is as below.
And now we should create the newModule class file which act as the Model for this module. Actually you can develop this module without following the MVC pattern. But it’s strongly recommended to follow these design patterns if your project is a real one. The content of the “newModule.php” is as follows.
At this point, we have finished developing the Model and Controller. Now the view file (at least one) should be created. Vtiger uses Smarty as a presentation framework. So, the view is a Smarty template. In our example – “newModule.tpl” , and it’s content is given below.
All the required files for our new module were created now. The next thing we should do is attach this module to the System.
At the moment, there is not any automated module management (install, uninstall etc...) facilities in vtiger. Therefore, you can follow the steps given below to attach our new module to the system.
Basically, we should edit following files and inset the some data to the following tables to achieve this goal.
Files->
parent_tabdata.php
tabdata.php
include/language/en_us.lang.php
Tables->
vtiger_tab, vtiger_parenttab, vtiger_parenttabrel
parent_tabdata.php:
In this file, there is an array called “$parent_tab_info_array”. An element should be entered to this array to show our module in the menu. For this example I will edit the array as given below.
Befor:
$parent_tab_info_array=array(1=>'My Home Page',2=>'Marketing',3=>'Sales',4=>'Support',
5=>'Analytics',6=>'Inventory',7=>'Tools',8=>'Settings',9=>'Nadeeth',10=>'newModule');
After:
$parent_tab_info_array=array(1=>'My Home Page',2=>'Marketing',3=>'Sales',4=>'Support',5=>'Analytics',
6=>'Inventory',7=>'Tools',8=>'Settings',9=>'Nadeeth',10=>'newModule');
At the end, new element “10=>'newModule'” is added.
Tabdata.php:
In this file there is an array called “$tab_info_array” which contains the details about sub menus. New element should be added into this array for our new module.
Before:
$tab_info_array=array('Home'=>3,'Leads'=>7,'Accounts'=>6,'Contacts'=>4,
'Potentials'=>2,'Notes'=>8,'Calendar'=>9,'Emails'=>10,'HelpDesk'=>13,
'Products'=>14,'Dashboard'=>1,'Faq'=>15,'Events'=>16,'Vendors'=>18,
'PriceBooks'=>19,'Quotes'=>20,'PurchaseOrder'=>21,'SalesOrder'=>22,
'Invoice'=>23,'Rss'=>24,'Reports'=>25,'Campaigns'=>26,'Portal'=>27,
'Webmails'=>28,'Users'=>29, 'Nadeeth'=>30);
After:
$tab_info_array=array('Home'=>3,'Leads'=>7,'Accounts'=>6,'Contacts'=>4,
'Potentials'=>2,'Notes'=>8,'Calendar'=>9,'Emails'=>10,'HelpDesk'=>13,
'Products'=>14,'Dashboard'=>1,'Faq'=>15,'Events'=>16,'Vendors'=>18,
'PriceBooks'=>19,'Quotes'=>20,'PurchaseOrder'=>21,'SalesOrder'=>22,
'Invoice'=>23,'Rss'=>24,'Reports'=>25,'Campaigns'=>26,'Portal'=>27,
'Webmails'=>28,'Users'=>29, 'Nadeeth'=>30, 'newModule'=>31);
See, the element 'newModule'=>31 is added to the end. Remember, these indexes (in this case 31) should be modified according to the values in your system.
include/language/en_us.lang.php:
Now the language file should be modified. Just enter a new element for $app_strings array. For our example, please add the element given below.
'newModule' => 'newModule',
Next step is to add the data related to our module to the tables - vtiger_tab, vtiger_parenttab, vtiger_parenttabrel. The queries given below will do that for you. Here also, please remember to change the values to match with the existing data of your system.
INSERT INTO `vtiger_tab` (`tabid`, `name`, `presence`, `tabsequence`, `tablabel`, `modifiedby`, `modifiedtime`, customized`, `ownedby`) VALUES(31, 'newModule', 1, 31, 'newModule', NULL, NULL, NULL, NULL);
INSERT INTO `vtiger_parenttab` (`parenttabid`, `parenttab_label`, `sequence`, `visible`) VALUES(10, 'newModule', 10, 0);
INSERT INTO `vtiger_parenttabrel` (`parenttabid`, `tabid`, `sequence`) VALUES(10, 31, 1);
Now, we have finished crating new module. Log into the system and you can see there is a new menu in the menu bar.
And new module is installed.
Step 01: Creating the module directory and minimum required files.
Create a directory called “newModule” inside your vtiger modules directory, or any other name that you prefer. Now, module index file should be created. Create a new file called “index.php” inside the “newModule” directory and insert following code.
And next the “ListView.php” file should be created. This name “ListView” is not compulsory. In fact, you can include any script that you prefer to run when the users are entering to the module. The content of the “ListView.php” is as below.
And now we should create the newModule class file which act as the Model for this module. Actually you can develop this module without following the MVC pattern. But it’s strongly recommended to follow these design patterns if your project is a real one. The content of the “newModule.php” is as follows.
At this point, we have finished developing the Model and Controller. Now the view file (at least one) should be created. Vtiger uses Smarty as a presentation framework. So, the view is a Smarty template. In our example – “newModule.tpl” , and it’s content is given below.
All the required files for our new module were created now. The next thing we should do is attach this module to the System.
Step 02: Attach new module to the vtiger.
At the moment, there is not any automated module management (install, uninstall etc...) facilities in vtiger. Therefore, you can follow the steps given below to attach our new module to the system.
Basically, we should edit following files and inset the some data to the following tables to achieve this goal.
Files->
parent_tabdata.php
tabdata.php
include/language/en_us.lang.php
Tables->
vtiger_tab, vtiger_parenttab, vtiger_parenttabrel
parent_tabdata.php:
In this file, there is an array called “$parent_tab_info_array”. An element should be entered to this array to show our module in the menu. For this example I will edit the array as given below.
Befor:
$parent_tab_info_array=array(1=>'My Home Page',2=>'Marketing',3=>'Sales',4=>'Support',
5=>'Analytics',6=>'Inventory',7=>'Tools',8=>'Settings',9=>'Nadeeth',10=>'newModule');
After:
$parent_tab_info_array=array(1=>'My Home Page',2=>'Marketing',3=>'Sales',4=>'Support',5=>'Analytics',
6=>'Inventory',7=>'Tools',8=>'Settings',9=>'Nadeeth',10=>'newModule');
At the end, new element “10=>'newModule'” is added.
Tabdata.php:
In this file there is an array called “$tab_info_array” which contains the details about sub menus. New element should be added into this array for our new module.
Before:
$tab_info_array=array('Home'=>3,'Leads'=>7,'Accounts'=>6,'Contacts'=>4,
'Potentials'=>2,'Notes'=>8,'Calendar'=>9,'Emails'=>10,'HelpDesk'=>13,
'Products'=>14,'Dashboard'=>1,'Faq'=>15,'Events'=>16,'Vendors'=>18,
'PriceBooks'=>19,'Quotes'=>20,'PurchaseOrder'=>21,'SalesOrder'=>22,
'Invoice'=>23,'Rss'=>24,'Reports'=>25,'Campaigns'=>26,'Portal'=>27,
'Webmails'=>28,'Users'=>29, 'Nadeeth'=>30);
After:
$tab_info_array=array('Home'=>3,'Leads'=>7,'Accounts'=>6,'Contacts'=>4,
'Potentials'=>2,'Notes'=>8,'Calendar'=>9,'Emails'=>10,'HelpDesk'=>13,
'Products'=>14,'Dashboard'=>1,'Faq'=>15,'Events'=>16,'Vendors'=>18,
'PriceBooks'=>19,'Quotes'=>20,'PurchaseOrder'=>21,'SalesOrder'=>22,
'Invoice'=>23,'Rss'=>24,'Reports'=>25,'Campaigns'=>26,'Portal'=>27,
'Webmails'=>28,'Users'=>29, 'Nadeeth'=>30, 'newModule'=>31);
See, the element 'newModule'=>31 is added to the end. Remember, these indexes (in this case 31) should be modified according to the values in your system.
include/language/en_us.lang.php:
Now the language file should be modified. Just enter a new element for $app_strings array. For our example, please add the element given below.
'newModule' => 'newModule',
Next step is to add the data related to our module to the tables - vtiger_tab, vtiger_parenttab, vtiger_parenttabrel. The queries given below will do that for you. Here also, please remember to change the values to match with the existing data of your system.
INSERT INTO `vtiger_tab` (`tabid`, `name`, `presence`, `tabsequence`, `tablabel`, `modifiedby`, `modifiedtime`, customized`, `ownedby`) VALUES(31, 'newModule', 1, 31, 'newModule', NULL, NULL, NULL, NULL);
INSERT INTO `vtiger_parenttab` (`parenttabid`, `parenttab_label`, `sequence`, `visible`) VALUES(10, 'newModule', 10, 0);
INSERT INTO `vtiger_parenttabrel` (`parenttabid`, `tabid`, `sequence`) VALUES(10, 31, 1);
Now, we have finished crating new module. Log into the system and you can see there is a new menu in the menu bar.
And new module is installed.
Comments
http://nadeeth.info/blog/sites/default/files/newModule.zip
Thanks for your comment.
http://code.google.com/p/syntaxhighlighter/
It's javascript and it's fast. Give it a try ;)
Bye!
Warning: Invalid argument supplied for foreach() in D:\wamp\www\v-tiger\include\utils\CommonUtils.php on line 1306
kindly help
deepsingh
First of all thank you very much for posting this article.
While I was following your article for creating a Module in vtigerCRM 5.0.4, I got this strange error.
Invalid argument supplied for foreach() in /var/www/vtigercrm/include/utils/CommonUtils.php on line 1306
Can you please let me know where I went wrong.
Thanks & Regards,
Sreedhar
After all, I will try to find some time to do some works to find the changes in new version.
Thanks for your comment. Keep in touch...
Regards,
Kumar
one more to configure..
$parent_child_tab_rel_array=array(1=>array(3,9,28,),2=>array(26,6,4,28,7,9,8,),3=>array(7,6,4,2,20,22,23,14,19,8,9,),4=>array(13,15,6,4,14,8,28,9,),5=>array(1,25,),6=>array(14,18,19,21,22,20,23,),7=>array(24,27,8,),8=>array(),10=>array(31,),);
at the end, we added 10=>array(31,)
I have successfully installed the new module.. (with few tweaks because i am using vtiger 5.1.0)
Cheers!!
it helps me a lot...
until i found your guide thanks! keep it up
My version: 5.1.
I could install this well, once installed, I start the application , and I can see the "newModule" new menu option onto the menu bar, but, when I push this new link, an alert message appears:
"newModule module is not active!"
Please, could you tell me how should I activate the module?
Thanks a lot.
"Module name is missing. Please check the module name."
plz rep me
I have followed all the steps as guide - but the final result says
newModule module is not active
could anyone advise as how to resolve this issue, am working on vtigercrm 5.2.0
thanks
It was helpful... :)
I want to create 3 pieces of the accounts module.
Possible?
Are you can help me
Your blog helped me a lot.
Thanks and Regards
Baibhav Singh
please let me know the procedure ASAP
thanks a lot
Thanks& Regards.
i got this after sign in into vtiger
to rectify that error
Warning: Invalid argument supplied for foreach() in D:\wamp\www\v-tiger\include\utils\CommonUtils.php on line 1306 ??
thank you
this $app_strings = Array('HELLO_WORLD' => 'Hello World');
by this
$mod_strings = Array('HELLO_WORLD' => 'Hello World');
in lang file
this $app_strings = Array('HELLO_WORLD' => 'Hello World');
by this
$mod_strings = Array('HELLO_WORLD' => 'Hello World');
in lang file
How can i add my own field instead hello world!?
for example text field, check box, and it's must work of couse with database
Thank's
Thanks.
ts not found
I am facing some issues in creating a vTiger Module for vTiger 6.1. I would appreciate if you can share your Email or Skype.
Please get in touch at jiteen@technoscore.net or Skype : suntec.jiteen
I'm very confused that is where put these files ?. We put all files in C:\wamp\www\crm\modules\newModule but i don't no that location is right or wrong ?. and also talk me how it can be run ?