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.
Great article, but just one problem; why did you have to put the code examples as images? Surely copy-and-paste-able text would have been better...
ReplyDeleteYes, what you say is correct. But you can download the source code of this example from the download link in the beginning of the article.
ReplyDeletehttp://nadeeth.info/blog/sites/default/files/newModule.zip
Thanks for your comment.
I personally use Code Highlighter:
ReplyDeletehttp://code.google.com/p/syntaxhighlighter/
It's javascript and it's fast. Give it a try ;)
Bye!
Thanks Chris, I did see that. It's a nice tool.I will give it a try next time...
ReplyDeletei am getting an error and new tab is not shown :
ReplyDeleteWarning: Invalid argument supplied for foreach() in D:\wamp\www\v-tiger\include\utils\CommonUtils.php on line 1306
kindly help
deepsingh
Can you contact me in emails..? send your mail address using the contact form of this site... Thx...
ReplyDeleteHi Nadeeth,
ReplyDeleteFirst 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
DeleteHey, very nice site. I came across this on Google, and I am stoked that I did. I will definitely be coming back here more often. Wish I could add to the conversation and bring a bit more to the table,but am just taking in as much info as I can at the moment. Thanks for sharing.
Vissco Aluminium Wheelchair with Fixed Wheels
As I have mentioned in the beginning of this article, this module development tasks were done by me for vtiger 5.0.3 some time ago. And I haven't check it's compatibility with the newer versions. There may be some little differences, which can easily find reading the code and database.
ReplyDeleteAfter 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...
Thank you for you post, it's very useful.
ReplyDeletethx...it helps me a lot....
ReplyDeleteRegards,
Kumar
in parent_tabdata.php file:
ReplyDeleteone 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,)
Thanks a ton Nadeeth,
ReplyDeleteI have successfully installed the new module.. (with few tweaks because i am using vtiger 5.1.0)
Cheers!!
it's a very good tutorial, thanks.
ReplyDeletethanks u..
ReplyDeleteit helps me a lot...
i spent my whole day trying to add a new tab in the crm but failed..
ReplyDeleteuntil i found your guide thanks! keep it up
Hello
ReplyDeleteMy 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.
display newMudual but click onthis link error will be generate
ReplyDelete"Module name is missing. Please check the module name."
plz rep me
I appreciate your post to create a new module for vtiger, thanks for sharing the post, i would like to hear more about this in future
ReplyDeleterequest help please
ReplyDeleteI 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
Thnx a lot...
ReplyDeleteIt was helpful... :)
Hi,
ReplyDeleteI want to create 3 pieces of the accounts module.
Possible?
Are you can help me
Hi nadeeth,
ReplyDeleteYour blog helped me a lot.
Thanks and Regards
Baibhav Singh
good job dude... but couldnt find the language and $app_string...
ReplyDeleteplease let me know the procedure ASAP
thanks a lot
good job dude
ReplyDeleteThanks brother..........
ReplyDeleteHi, i would like to ask the "insert into" query is supposed to be written in which script? thanks.
ReplyDeleteYou have to use this query in your sql
Deletehi,i have tried to create a new module by using the above code,every thing is OK,but result will not come,it means,the newModule will not shown in menu am using vtigercrm5.4.0 ,please help me to completion of this work through email,my mail id is vtigercrmtool@gmail.com,plz send the answer to mail id ,if you have possible
ReplyDeleteThanks& Regards.
Warning: mysql_pconnect() [function.mysql-pconnect]: Can't connect to MySQL server on 'localhost' (10061) in C:\Program Files\vtigercrm-5.4.0\apache\htdocs\vtigerCRM\adodb\drivers\adodb-mysql.inc.php on line 373
ReplyDeletei got this after sign in into vtiger
Could you find the error???
Deleteplease tel me how
ReplyDeleteto rectify that error
Whats wrong ? why do i get an error message
ReplyDeleteWarning: Invalid argument supplied for foreach() in D:\wamp\www\v-tiger\include\utils\CommonUtils.php on line 1306 ??
This comment has been removed by the author.
ReplyDeleteHi, I can't see the new module in the menu bar, what can i do, Im using vtiger 5.4.0
ReplyDeletethank you
This comment has been removed by the author.
DeleteThank, i solved problem, by replacing
ReplyDeletethis $app_strings = Array('HELLO_WORLD' => 'Hello World');
by this
$mod_strings = Array('HELLO_WORLD' => 'Hello World');
in lang file
Thank, i solved problem, by replacing
ReplyDeletethis $app_strings = Array('HELLO_WORLD' => 'Hello World');
by this
$mod_strings = Array('HELLO_WORLD' => 'Hello World');
in lang file
Thank you very much for sharing what you found...
DeleteGood, it's works on my vtiger 5.4.0
ReplyDeleteHow 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
Actually I did this five years ago.. :-) So, at the moment I don't remember the way I added new fields. But I remember I did many modifications like those. Let me figure it out and let you know when I am free.
DeleteThanks.
Hi, awesome tutorial, btw can't find the source code file :(
ReplyDeleteWe are a team of experts who have a long and well experience in different open source systems, especially in vTiger ,
ReplyDeleteOur long experience gave us the opportunity to start on creating and developing to make vTiger a better CRM and to help vTiger users to be able to organize their business what ever it was,
By using our new modules and integrations you will be able to focus your manpower on bringing new opportunities and leave the rest to your CRM
Hello Noor, I am looking forward for creating a Module for vTiger 6.1.
DeleteIf you can be of any help, please get in touch at jiteen@technoscore.net OR Skype me at : suntec.jiteen
http://nadeeth.info/blog/sites/default/files/newModule.zip
ReplyDeletets not found
Hello Nadeth. First of all AWESOME TUTS.
ReplyDeleteI 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
Hi everyone
ReplyDeleteI'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 ?
Hello there! I found your blog using on Google. This is a really well written article. I will be sure to bookmark it and return to read more of your useful information. I’ll definitely return. Thanks for the post.
ReplyDeleteHandicap Tricycle Price
Deluxe Tricycle Handicapped
Keep Posting:)
ReplyDeletethanks for your information really good and very nice web design company in velachery