[Vtigercrm-developers] Creating a module extension for ver 5.4

lajeesh k lajeeshk at gmail.com
Sat Jun 21 04:23:04 GMT 2014


Follow the following sample for creating new field,


<?php
$Vtiger_Utils_Log = true;
require_once('vtlib/Vtiger/Module.php');
require_once('vtlib/Vtiger/Block.php');
require_once('vtlib/Vtiger/Field.php');

$module = Vtiger_Module::getInstance('Project');

if($module)
{
    $block    =
Vtiger_Block::getInstance('LBL_PROJECT_INFORMATION',$module);

    if($block)
    {
        $field = Vtiger_Field::getInstance('hours',$module);
        if(!$field)
        {
            $field = new Vtiger_Field();
            $field->name = 'hours';
            $field->table = 'vtiger_project';
            $field->label = 'Hours';
            $field->column = 'hours';
            $field->columntype = 'VARCHAR(40)';
            $field->uitype = 7;
            $field->displaytype = 2;
            $field->typeofdata = 'V~O';
            $block->addField($field);
        }
    }
    else
    {
        echo "No block";
    }
}
else
{
    echo "No module";
}



?>


On Sat, Jun 21, 2014 at 12:24 AM, Send Review <sendreview at gmail.com> wrote:

> Hello,
>
> I am trying to add parameters in the "my preferences", that could be used
> in order to activate/deactivate customizations.
>
> From my understanding, this is best done with a module extension. So I
> created the bootstrap code to be run in order to modify the database.
>
> <?php
>> include_once('vtlib/Vtiger/Module.php');
>> $module = new Vtiger_Module();
>> $module->name = 'Users';
>> $module->id = 29;
>> $module->save();
>> // Initialize all the tables required
>> $module->initTables();
>> // Add the basic module block
>> $block1 = new Vtiger_Block();
>> $block1->label = 'Personal Config';
>> $module->addBlock($block1);
>> /** Create required fields and add to the block */
>> $field1 = new Vtiger_Field();
>> $field1->name = 'rail1';
>> $field1->table = $module->basetable;
>> $field1->column = 'rail1';
>> $field1->label = 'Activity rail1';
>> $field1->columntype = 'VARCHAR(255)';
>> $field1->uitype = 33;
>> $field1->typeofdata = 'V~M';
>> $field1->setPicklistValues( Array ('rail', 'Todo') );
>> $field1->defaultvalue ='rail';
>> $block1->addField($field1);
>> ?>
>>
>
> By forcing
>
> $module->name = 'Users';
>> $module->id = 29;
>
>
> the modification will occur on the vtiger_users table, which is what I am
> trying to do.
>
> Questions:
> - is this the proper way to extend a module like users?
> - the modification is not extracted via the module manager. So that means
> I cannot distribute this user table change.
>
> What should be the right approach?
>
> Thanks, Joel
>
>
>
> _______________________________________________
> http://www.vtiger.com/
>



-- 

Regards,
Lajeesh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20140621/0931772e/attachment.html>


More information about the vtigercrm-developers mailing list