Results 1 to 8 of 8

Thread: Default values in modules fields

  1. #1
    New user
    Join Date
    08-10-10.
    Posts
    10

    Default 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,

  2. #2

    Default 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;
    OM MANI PEME HUNG! how many has to die for freedom and dignity. Save this world

  3. #3
    Experienced user
    Join Date
    06-10-09.
    Location
    Cape Town, South Africa
    Posts
    1,387

    Default Re: Default values in modules fields

    This would be a default value setting:

    Code:
    $GLOBALS['TL_DCA']['tl_gallery']['fields']['perRow']['default'] = 6;

  4. #4
    New user
    Join Date
    08-10-10.
    Posts
    10

    Default 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?

  5. #5
    New user
    Join Date
    08-10-10.
    Posts
    10

    Default 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:


    Thanks for helping me

  6. #6

    Default 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
    OM MANI PEME HUNG! how many has to die for freedom and dignity. Save this world

  7. #7
    New user
    Join Date
    08-10-10.
    Posts
    10

    Default 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

  8. #8
    Experienced user
    Join Date
    06-10-09.
    Location
    Cape Town, South Africa
    Posts
    1,387

    Default 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');

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •