<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body><div><div style="font-family: Calibri,sans-serif; font-size: 11pt;">Hi,<br><br>This given example for creating new field in existing block of existing module..just run this script..and u can see a new field in existing project module..<br><br>Regards<br>Lajeesh</div></div><div dir="ltr"><hr><span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;">From: </span><span style="font-family: Calibri,sans-serif; font-size: 11pt;"><a href="mailto:sendreview@gmail.com">Send Review</a></span><br><span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;">Sent: </span><span style="font-family: Calibri,sans-serif; font-size: 11pt;">21-06-2014 20:23</span><br><span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;">To: </span><span style="font-family: Calibri,sans-serif; font-size: 11pt;"><a href="mailto:vtigercrm-developers@lists.vtigercrm.com">vtigercrm-developers@lists.vtigercrm.com</a></span><br><span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;">Subject: </span><span style="font-family: Calibri,sans-serif; font-size: 11pt;">[Vtigercrm-developers] Creating a module extension for ver 5.4</span><br><br></div><div dir="ltr"><div><span style="font-family: arial,sans-serif; font-size: 13px;">Hello,</span></div><div><span style="font-family: arial,sans-serif; font-size: 13px;"><br></span></div><div><span style="font-family: arial,sans-serif; font-size: 13px;">Thanks for the kind reply. However, this example shows how to create a new field for a new new block in a new module.</span></div>
<div><span style="font-family: arial,sans-serif; font-size: 13px;"><br></span></div><div><span style="font-family: arial,sans-serif; font-size: 13px;">What I am looking for, is to create a new field in existing user module so that I have new parameter in the "My preference" user option. In other words, I am not creating a new module and forces the new block and field to the existing user module:</span></div>
<div><br></div><div><pre><i>> $module->name = 'Users';
</i>><i> $module->id = 29;</i></pre></div><div style="font-family: arial,sans-serif; font-size: 13px;"><span style="font-family: arial,sans-serif; font-size: 13px;"><br></span></div><div style="font-family: arial,sans-serif; font-size: 13px;">
<span style="font-family: arial,sans-serif; font-size: 13px;">I wonder if this is good practice.</span></div><div style="font-family: arial,sans-serif; font-size: 13px;"><span style="font-family: arial,sans-serif; font-size: 13px;"><br>
</span></div><div style="font-family: arial,sans-serif; font-size: 13px;"><span style="font-family: arial,sans-serif; font-size: 13px;">Secondly, since I am not creating a new module instance, it will not appear in the module manager. So that means it will not be exportable. I wonder what should be the approach.</span></div>
<div style="font-family: arial,sans-serif; font-size: 13px;"><span style="font-family: arial,sans-serif; font-size: 13px;"><br></span></div><div><font face="arial, sans-serif">I looked pretty much around the web for example of module extension (not how to create a new module) but could not find any literature.</font></div>
<div style="font-family: arial,sans-serif; font-size: 13px;"><span style="font-family: arial,sans-serif; font-size: 13px;"><br></span></div><div style="font-family: arial,sans-serif; font-size: 13px;"><span style="font-family: arial,sans-serif; font-size: 13px;">Thanks, Joel</span></div>
<div style="font-family: arial,sans-serif; font-size: 13px;"><span style="font-family: arial,sans-serif; font-size: 13px;"><br></span></div><div style="font-family: arial,sans-serif; font-size: 13px;"><span style="font-family: arial,sans-serif; font-size: 13px;"><br>
</span></div><div style="font-family: arial,sans-serif; font-size: 13px;"><span style="font-family: arial,sans-serif; font-size: 13px;"><br></span></div><font face="arial, sans-serif">Message: 1</font><br style="font-family: arial,sans-serif; font-size: 13px;">
<span style="font-family: arial,sans-serif; font-size: 13px;">Date: Sat, 21 Jun 2014 09:53:04 +0530</span><br style="font-family: arial,sans-serif; font-size: 13px;"><span style="font-family: arial,sans-serif; font-size: 13px;">From: lajeesh k <</span><a style="font-family: arial,sans-serif; font-size: 13px;" href="mailto:lajeeshk@gmail.com">lajeeshk@gmail.com</a><span style="font-family: arial,sans-serif; font-size: 13px;">></span><br style="font-family: arial,sans-serif; font-size: 13px;">
<span style="font-family: arial,sans-serif; font-size: 13px;">To: vtigercrm-developers <</span><a style="font-family: arial,sans-serif; font-size: 13px;" href="mailto:vtigercrm-developers@lists.vtigercrm.com">vtigercrm-developers@lists.vtigercrm.com</a><span style="font-family: arial,sans-serif; font-size: 13px;">></span><br style="font-family: arial,sans-serif; font-size: 13px;">
<span style="font-family: arial,sans-serif; font-size: 13px;">Subject: Re: [Vtigercrm-developers] Creating a module extension for</span><br style="font-family: arial,sans-serif; font-size: 13px;"><span style="font-family: arial,sans-serif; font-size: 13px;"> ver 5.4</span><br style="font-family: arial,sans-serif; font-size: 13px;">
<span style="font-family: arial,sans-serif; font-size: 13px;">Message-ID:</span><br style="font-family: arial,sans-serif; font-size: 13px;"><span style="font-family: arial,sans-serif; font-size: 13px;"> <</span><a style="font-family: arial,sans-serif; font-size: 13px;" href="mailto:CAA1bLmpB4uTuZ0nJtvJ2NVdfXcvooGSJvRkPJexnhtMJTrqwkg@mail.gmail.com">CAA1bLmpB4uTuZ0nJtvJ2NVdfXcvooGSJvRkPJexnhtMJTrqwkg@mail.gmail.com</a><span style="font-family: arial,sans-serif; font-size: 13px;">></span><br style="font-family: arial,sans-serif; font-size: 13px;">
<span style="font-family: arial,sans-serif; font-size: 13px;">Content-Type: text/plain; charset="utf-8"</span><br style="font-family: arial,sans-serif; font-size: 13px;"><br style="font-family: arial,sans-serif; font-size: 13px;">
<span style="font-family: arial,sans-serif; font-size: 13px;">Follow the following sample for creating new field,</span><br style="font-family: arial,sans-serif; font-size: 13px;"><br style="font-family: arial,sans-serif; font-size: 13px;">
<br style="font-family: arial,sans-serif; font-size: 13px;"><span style="font-family: arial,sans-serif; font-size: 13px;"><?php</span><br style="font-family: arial,sans-serif; font-size: 13px;"><span style="font-family: arial,sans-serif; font-size: 13px;">$Vtiger_Utils_Log = true;</span><br style="font-family: arial,sans-serif; font-size: 13px;">
<span style="font-family: arial,sans-serif; font-size: 13px;">require_once('vtlib/Vtiger/</span><span style="font-family: arial,sans-serif; font-size: 13px;">Module.php');</span><br style="font-family: arial,sans-serif; font-size: 13px;">
<span style="font-family: arial,sans-serif; font-size: 13px;">require_once('vtlib/Vtiger/</span><span style="font-family: arial,sans-serif; font-size: 13px;">Block.php');</span><br style="font-family: arial,sans-serif; font-size: 13px;">
<span style="font-family: arial,sans-serif; font-size: 13px;">require_once('vtlib/Vtiger/</span><span style="font-family: arial,sans-serif; font-size: 13px;">Field.php');</span><br style="font-family: arial,sans-serif; font-size: 13px;">
<br style="font-family: arial,sans-serif; font-size: 13px;"><span style="font-family: arial,sans-serif; font-size: 13px;">$module = Vtiger_Module::getInstance('</span><span style="font-family: arial,sans-serif; font-size: 13px;">Project');</span><br style="font-family: arial,sans-serif; font-size: 13px;">
<br style="font-family: arial,sans-serif; font-size: 13px;"><span style="font-family: arial,sans-serif; font-size: 13px;">if($module)</span><br style="font-family: arial,sans-serif; font-size: 13px;"><span style="font-family: arial,sans-serif; font-size: 13px;">{</span><br style="font-family: arial,sans-serif; font-size: 13px;">
<span style="font-family: arial,sans-serif; font-size: 13px;"> $block =</span><br style="font-family: arial,sans-serif; font-size: 13px;"><span style="font-family: arial,sans-serif; font-size: 13px;">Vtiger_Block::getInstance('</span><span style="font-family: arial,sans-serif; font-size: 13px;">LBL_PROJECT_INFORMATION',$</span><span style="font-family: arial,sans-serif; font-size: 13px;">module);</span><br style="font-family: arial,sans-serif; font-size: 13px;">
<br style="font-family: arial,sans-serif; font-size: 13px;"><span style="font-family: arial,sans-serif; font-size: 13px;"> if($block)</span><br style="font-family: arial,sans-serif; font-size: 13px;"><span style="font-family: arial,sans-serif; font-size: 13px;"> {</span><br style="font-family: arial,sans-serif; font-size: 13px;">
<span style="font-family: arial,sans-serif; font-size: 13px;"> $field = Vtiger_Field::getInstance('</span><span style="font-family: arial,sans-serif; font-size: 13px;">hours',$module);</span><br style="font-family: arial,sans-serif; font-size: 13px;">
<span style="font-family: arial,sans-serif; font-size: 13px;"> if(!$field)</span><br style="font-family: arial,sans-serif; font-size: 13px;"><span style="font-family: arial,sans-serif; font-size: 13px;"> {</span><br style="font-family: arial,sans-serif; font-size: 13px;">
<span style="font-family: arial,sans-serif; font-size: 13px;"> $field = new Vtiger_Field();</span><br style="font-family: arial,sans-serif; font-size: 13px;"><span style="font-family: arial,sans-serif; font-size: 13px;"> $field->name = 'hours';</span><br style="font-family: arial,sans-serif; font-size: 13px;">
<span style="font-family: arial,sans-serif; font-size: 13px;"> $field->table = 'vtiger_project';</span><br style="font-family: arial,sans-serif; font-size: 13px;"><span style="font-family: arial,sans-serif; font-size: 13px;"> $field->label = 'Hours';</span><br style="font-family: arial,sans-serif; font-size: 13px;">
<span style="font-family: arial,sans-serif; font-size: 13px;"> $field->column = 'hours';</span><br style="font-family: arial,sans-serif; font-size: 13px;"><span style="font-family: arial,sans-serif; font-size: 13px;"> $field->columntype = 'VARCHAR(40)';</span><br style="font-family: arial,sans-serif; font-size: 13px;">
<span style="font-family: arial,sans-serif; font-size: 13px;"> $field->uitype = 7;</span><br style="font-family: arial,sans-serif; font-size: 13px;"><span style="font-family: arial,sans-serif; font-size: 13px;"> $field->displaytype = 2;</span><br style="font-family: arial,sans-serif; font-size: 13px;">
<span style="font-family: arial,sans-serif; font-size: 13px;"> $field->typeofdata = 'V~O';</span><br style="font-family: arial,sans-serif; font-size: 13px;"><span style="font-family: arial,sans-serif; font-size: 13px;"> $block->addField($field);</span><br style="font-family: arial,sans-serif; font-size: 13px;">
<span style="font-family: arial,sans-serif; font-size: 13px;"> }</span><br style="font-family: arial,sans-serif; font-size: 13px;"><span style="font-family: arial,sans-serif; font-size: 13px;"> }</span><br style="font-family: arial,sans-serif; font-size: 13px;">
<span style="font-family: arial,sans-serif; font-size: 13px;"> else</span><br style="font-family: arial,sans-serif; font-size: 13px;"><span style="font-family: arial,sans-serif; font-size: 13px;"> {</span><br style="font-family: arial,sans-serif; font-size: 13px;">
<span style="font-family: arial,sans-serif; font-size: 13px;"> echo "No block";</span><br style="font-family: arial,sans-serif; font-size: 13px;"><span style="font-family: arial,sans-serif; font-size: 13px;"> }</span><br style="font-family: arial,sans-serif; font-size: 13px;">
<span style="font-family: arial,sans-serif; font-size: 13px;">}</span><br style="font-family: arial,sans-serif; font-size: 13px;"><span style="font-family: arial,sans-serif; font-size: 13px;">else</span><br style="font-family: arial,sans-serif; font-size: 13px;">
<span style="font-family: arial,sans-serif; font-size: 13px;">{</span><br style="font-family: arial,sans-serif; font-size: 13px;"><span style="font-family: arial,sans-serif; font-size: 13px;"> echo "No module";</span><br style="font-family: arial,sans-serif; font-size: 13px;">
<span style="font-family: arial,sans-serif; font-size: 13px;">}</span><br style="font-family: arial,sans-serif; font-size: 13px;"><br style="font-family: arial,sans-serif; font-size: 13px;"><br style="font-family: arial,sans-serif; font-size: 13px;">
<br style="font-family: arial,sans-serif; font-size: 13px;"><span style="font-family: arial,sans-serif; font-size: 13px;">?></span><br></div>
</body></html>