{"id":8684,"date":"2024-07-10T06:06:51","date_gmt":"2024-07-10T06:06:51","guid":{"rendered":"https:\/\/www.infinitivehost.com\/knowledge-base\/?p=8684"},"modified":"2024-08-23T08:09:43","modified_gmt":"2024-08-23T08:09:43","slug":"create-custom-module-in-vtiger7-with-vtlib-step-by-step-guide","status":"publish","type":"post","link":"https:\/\/www.infinitivehost.com\/knowledge-base\/create-custom-module-in-vtiger7-with-vtlib-step-by-step-guide\/","title":{"rendered":"Create Custom Module in vTiger7 with vtlib: Step-by-Step Guide"},"content":{"rendered":"<div class='epvc-post-count'><span class='epvc-eye'><\/span>  <span class=\"epvc-count\"> 1,961<\/span><span class='epvc-label'> Views<\/span><\/div>\n<p>Creating a custom module in vTiger7 using vtlib involves several steps. Here is a step-by-step guide to help you through the process:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: Set Up Your Environment<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Backup<\/strong>: Always take a backup of your current vTiger instance, including the database.<\/li>\n\n\n\n<li><strong>Environment<\/strong>: Ensure you have a working vTiger 7 instance and access to the server.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2: Create the Basic Structure<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Folder Structure<\/strong>: Navigate to <code>modules<\/code> directory in your vTiger installation and create a new folder for your custom module. For example, if your module is named &#8220;CustomModule&#8221;, create a folder named <code>CustomModule<\/code>.<\/li>\n\n\n\n<li><strong>Module File<\/strong>: Inside your <code>CustomModule<\/code> folder, create a file named <code>CustomModule.php<\/code>. This file will contain the class for your module.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: Define the Module Class<\/h3>\n\n\n\n<p>In <code>CustomModule.php<\/code>, define your module class:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">&lt;?php\n\ninclude_once 'modules\/Vtiger\/CRMEntity.php';\n\nclass CustomModule extends CRMEntity {\n    public $table_name = 'vtiger_custommodule';\n    public $table_index= 'custommoduleid';\n\n    \/\/ Define the mandatory table for supporting custom fields.\n    public $customFieldTable = Array('vtiger_custommodulecf', 'custommoduleid');\n\n    \/\/ Define the list of tables related to this module.\n    public $tab_name = Array('vtiger_crmentity', 'vtiger_custommodule', 'vtiger_custommodulecf');\n\n    public $tab_name_index = Array(\n        'vtiger_crmentity' =&gt; 'crmid',\n        'vtiger_custommodule' =&gt; 'custommoduleid',\n        'vtiger_custommodulecf'=&gt;'custommoduleid'\n    );\n\n    public $list_fields = Array (\n        'Custom Field' =&gt; Array('custommodule', 'customfield'),\n        'Assigned To' =&gt; Array('crmentity','smownerid')\n    );\n\n    public $list_fields_name = Array (\n        'Custom Field' =&gt; 'customfield',\n        'Assigned To' =&gt; 'assigned_user_id'\n    );\n\n    public $list_link_field = 'customfield';\n\n    public $search_fields = Array(\n        'Custom Field' =&gt; Array('custommodule', 'customfield')\n    );\n\n    public $search_fields_name = Array (\n        'Custom Field' =&gt; 'customfield'\n    );\n\n    public $popup_fields = Array ('customfield');\n\n    public $def_basicsearch_col = 'customfield';\n\n    public $def_detailview_recname = 'customfield';\n\n    public $mandatory_fields = Array('customfield', 'assigned_user_id');\n\n    public $default_order_by = 'customfield';\n    public $default_sort_order='ASC';\n}\n?&gt;<\/mark><\/code><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Step 4: Create the Installation Script<\/h3>\n\n\n\n<p>Create an installation script to register your module. Create a file named <code>manifest.xml<\/code> in the <code>CustomModule<\/code> directory:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">&lt;?xml version=\"1.0\"?&gt;\n&lt;module&gt;\n    &lt;name&gt;CustomModule&lt;\/name&gt;\n    &lt;label&gt;Custom Module&lt;\/label&gt;\n    &lt;parent&gt;Tools&lt;\/parent&gt;\n    &lt;version&gt;1.0&lt;\/version&gt;\n    &lt;type&gt;entity&lt;\/type&gt;\n    &lt;php_version&gt;5.2&lt;\/php_version&gt;\n    &lt;dependencies&gt;\n        &lt;vtiger_version&gt;7.0&lt;\/vtiger_version&gt;\n    &lt;\/dependencies&gt;\n    &lt;tables&gt;\n        &lt;table&gt;\n            &lt;name&gt;vtiger_custommodule&lt;\/name&gt;\n            &lt;engine&gt;InnoDB&lt;\/engine&gt;\n            &lt;fields&gt;\n                &lt;field&gt;\n                    &lt;name&gt;custommoduleid&lt;\/name&gt;\n                    &lt;type&gt;int&lt;\/type&gt;\n                    &lt;nullable&gt;false&lt;\/nullable&gt;\n                    &lt;key&gt;PRI&lt;\/key&gt;\n                    &lt;extra&gt;auto_increment&lt;\/extra&gt;\n                &lt;\/field&gt;\n                &lt;field&gt;\n                    &lt;name&gt;customfield&lt;\/name&gt;\n                    &lt;type&gt;varchar&lt;\/type&gt;\n                    &lt;nullable&gt;false&lt;\/nullable&gt;\n                    &lt;length&gt;255&lt;\/length&gt;\n                &lt;\/field&gt;\n            &lt;\/fields&gt;\n        &lt;\/table&gt;\n        &lt;table&gt;\n            &lt;name&gt;vtiger_custommodulecf&lt;\/name&gt;\n            &lt;engine&gt;InnoDB&lt;\/engine&gt;\n            &lt;fields&gt;\n                &lt;field&gt;\n                    &lt;name&gt;custommoduleid&lt;\/name&gt;\n                    &lt;type&gt;int&lt;\/type&gt;\n                    &lt;nullable&gt;false&lt;\/nullable&gt;\n                    &lt;key&gt;PRI&lt;\/key&gt;\n                &lt;\/field&gt;\n            &lt;\/fields&gt;\n        &lt;\/table&gt;\n    &lt;\/tables&gt;\n&lt;\/module&gt;<\/mark><\/code><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Step 5: Install the Module<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Upload the Folder<\/strong>: Upload your <code>CustomModule<\/code> folder to the <code>modules<\/code> directory of your vTiger installation.<\/li>\n\n\n\n<li><strong>Install via vtiger<\/strong>: Log in to vTiger as an administrator, go to the Module Management section, and use the &#8220;Import Module&#8221; feature to upload and install your <code>CustomModule<\/code>.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Step 6: Configure the Module<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Create Fields<\/strong>: Use the Layout Editor in vTiger to add fields to your module as needed.<\/li>\n\n\n\n<li><strong>Permissions<\/strong>: Set permissions for roles to access the new module.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Step 7: Test Your Module<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Verify Installation<\/strong>: Check that the module appears in the CRM and that you can create, view, edit, and delete records.<\/li>\n\n\n\n<li><strong>Debug<\/strong>: If there are any issues, check the <code>vTiger.log<\/code> and <code>PHP error logs<\/code> for troubleshooting.<\/li>\n<\/ol>\n\n\n\n<p>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.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>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 <a href=\"https:\/\/www.infinitivehost.com\/managed-vtiger-solutions\"><mark style=\"background-color:#8ed1fc\" class=\"has-inline-color has-black-color\"><strong>best vtiger hosting solutions<\/strong><\/mark><\/a>, then you must find out the best service providers like Infinitive Host to get budget-friendly solutions.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1,961 Views 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 Step 2: Create the Basic Structure Step 3: Define the Module Class In CustomModule.php, define your module class: Step 4: Create the Installation Script Create [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[204],"tags":[83,112,13,87,162],"class_list":["post-8684","post","type-post","status-publish","format-standard","hentry","category-vtiger-solutions","tag-cpanel","tag-cpaneltutorial","tag-server","tag-web-hosting","tag-whm"],"_links":{"self":[{"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/posts\/8684","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/comments?post=8684"}],"version-history":[{"count":2,"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/posts\/8684\/revisions"}],"predecessor-version":[{"id":8889,"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/posts\/8684\/revisions\/8889"}],"wp:attachment":[{"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/media?parent=8684"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/categories?post=8684"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/tags?post=8684"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}