Default values in modules fields
Hi,
Is there a way to add default values in some particular modules in back-office?!
For example, I need Gallery module fields to appear always with default values I'm using for that website. This will prevent me to continually type those values.
Thanks in advance,
Re: Default values in modules fields
Which and what value?
You can do it in dcaconfig.php file.
For example, following will ask for minimum length for alternative text to be of 8 characters.
Code:
$GLOBALS['TL_DCA']['tl_content']['fields']['alt']['eval']['minlength'] = 8;
Re: Default values in modules fields
This would be a default value setting:
Code:
$GLOBALS['TL_DCA']['tl_gallery']['fields']['perRow']['default'] = 6;
Re: Default values in modules fields
Sorry the late reply and thanks for posting.
I've try what you both said and none work.
Code:
$GLOBALS['TL_DCA']['tl_gallery']['fields']['size']['width']['default'] = 150;
$GLOBALS['TL_DCA']['tl_gallery']['fields']['size']['height']['default'] = 100;
$GLOBALS['TL_DCA']['tl_gallery']['fields']['imagemargin']['top']['default'] = 18;
$GLOBALS['TL_DCA']['tl_gallery']['fields']['imagemargin']['right']['default'] = 18;
$GLOBALS['TL_DCA']['tl_gallery']['fields']['imagemargin']['unit']['default'] = 'px';
$GLOBALS['TL_DCA']['tl_gallery']['fields']['perRow']['default'] = 4;
$GLOBALS['TL_DCA']['tl_gallery']['fields']['perPage']['default'] = 24;
$GLOBALS['TL_DCA']['tl_gallery']['fields']['fullsize']['default'] = true;
and
Code:
$GLOBALS['TL_DCA']['tl_content']['fields']['size']['eval']['width'] = 150;
$GLOBALS['TL_DCA']['tl_content']['fields']['size']['eval']['height'] = 100;
$GLOBALS['TL_DCA']['tl_content']['fields']['imagemargin']['eval']['top'] = 18;
$GLOBALS['TL_DCA']['tl_content']['fields']['imagemargin']['eval']['right'] = 18;
$GLOBALS['TL_DCA']['tl_content']['fields']['imagemargin']['eval']['unit'] = 'px';
$GLOBALS['TL_DCA']['tl_content']['fields']['perRow']['default'] = 4;
$GLOBALS['TL_DCA']['tl_content']['fields']['perPage']['default'] = 24;
$GLOBALS['TL_DCA']['tl_content']['fields']['fullsize']['default'] = true;
Any idea what I might doing wrong?
Re: Default values in modules fields
Those 3 configs are working now:
Code:
$GLOBALS['TL_DCA']['tl_content']['fields']['perRow']['default'] = 4;
$GLOBALS['TL_DCA']['tl_content']['fields']['perPage']['default'] = 24;
$GLOBALS['TL_DCA']['tl_content']['fields']['fullsize']['default'] = true;
I can't not set now the Image Size and Margins.
Edit:
Just manage to make it work with the following configuration:
Code:
$GLOBALS['TL_DCA']['tl_content']['fields']['size']['default']['0'] = 150; // width
$GLOBALS['TL_DCA']['tl_content']['fields']['size']['default']['1'] = 100; // height
$GLOBALS['TL_DCA']['tl_content']['fields']['size']['default']['3'] = 'crop'; // Exact dimensions
$GLOBALS['TL_DCA']['tl_content']['fields']['imagemargin']['default']['top'] = 18;
$GLOBALS['TL_DCA']['tl_content']['fields']['imagemargin']['default']['right'] = 18;
$GLOBALS['TL_DCA']['tl_content']['fields']['imagemargin']['default']['unit'] = 'px';
$GLOBALS['TL_DCA']['tl_content']['fields']['perRow']['default'] = 4;
$GLOBALS['TL_DCA']['tl_content']['fields']['perPage']['default'] = 24;
$GLOBALS['TL_DCA']['tl_content']['fields']['fullsize']['default'] = true;
It looks like this image in the backoffice:
http://img830.imageshack.us/img830/1...icegallery.png
Thanks for helping me ;)
Re: Default values in modules fields
Image size is stored as a serialized value in Database, so use for example
Code:
$GLOBALS['TL_DCA']['tl_gallery']['fields']['items_size'] = 'a:2:{i:0;s:3:"360";i:1;s:3:"465";}';
exact value you can look into Database and copy that. I think same should be for margin
Re: Default values in modules fields
Thanks for let me know. It may indeed be faster to set default values that way since we actually don't need to know all the field names. Will you next time ;)
Re: Default values in modules fields
Nope. The default value does NOT have to be serialized. You can just do this by shortening it:
Code:
$GLOBALS['TL_DCA']['tl_content']['fields']['size']['default'] = array(0=>217,2=>'crop');
$GLOBALS['TL_DCA']['tl_content']['fields']['imagemargin']['default'] = array('top'=>'18','right'=>18,'unit'=>'px');