[Vtigercrm-developers] Image as custom field

apcloic apcloic at gmail.com
Tue Feb 3 08:17:25 GMT 2015


Hi,

You have to use and adapt an existing insertIntoAttachment function (for
example from /modules/Contacts/Contact.php)

Don't forget to include it in save_module function :
$this->insertIntoAttachment($this->id,$module);

Add public function getImageDetails in
/modules/your_module/models/Record.php (copy the one from Contacts module)

...and also add the following piece of code in
modules/your_module/actions/Save.php, something like :
$result = Vtiger_Util_Helper::transformUploadedFiles($_FILES, true);
$_FILES = $result['imagename'];

To display your image, there is also some little code to add in views files
/ public function process
/modules/your_module/views/Edit.php
		$viewer = $this->getViewer($request);
		$viewer->assign('IMAGE_DETAILS', $recordModel->getImageDetails());
/modules/your_module/views/Detail.php / function __construct
		$viewer = $this->getViewer($request);
		$viewer->assign('IMAGE_DETAILS', $recordModel->getImageDetails());

Finally, you have to add registerEventForImageGraphics function in
/layouts/vlayout/modules/your_module/resources/Detail.js, something like :

Vtiger_Detail_Js("Your_Module_Detail_Js",{},{
	
	/**
	 * Function to register event for image graphics
	 */
	registerEventForImageGraphics : function(){
		var imageContainer = jQuery('#imageContainer');
		imageContainer.cycle({ 
			fx:    'curtainX', 
			sync:  false, 
			speed:1000,
			timeout:20
		 });
		 imageContainer.find('img').on('mouseenter',function(){
			 imageContainer.cycle('pause');
		 }).on('mouseout',function(){
			 imageContainer.cycle('resume');
		 })
	},
	
	/**
	 * Function to register events
	 */
	registerEvents : function(){
		this._super();
		this.registerEventForImageGraphics();
	}
})

Regards,








--
View this message in context: http://vtiger-crm.2324883.n4.nabble.com/Vtigercrm-developers-Image-as-custom-field-tp15129p15168.html
Sent from the vtigercrm-developers mailing list archive at Nabble.com.


More information about the vtigercrm-developers mailing list