Hab es damit versucht. Funktioniert leider nicht.
initconfig.php
PHP-Code:
<?php
// Put your custom configuration here
// callback für dynamische Default-Werte aufrufen:
$GLOBALS['TL_DCA']['tl_content']['config']['onload_callback'][] = array('dynamicDefaults','set_defaults');
dynamicDefaults.php
PHP-Code:
<?php
/**
* Namespace
*/
namespace dynamicDefaults;
/**
* Class dynamicDefaults
*
*/
class dynamicDefaults extends \Backend
{
public function set_defaults($dc)
{
if ($_POST || Input::get('act') != 'edit')
{
return;
}
$objCte = ContentModel::findByPk($dc->id);
if ($objCte === null)
{
return;
}
switch ($objCte->type)
{
case 'gallery':
// Default image size - width, height, mode|size-ID
$GLOBALS['TL_DCA']['tl_content']['fields']['size']['default'] = array('', '', 1);
break;
case 'image':
// Default image size - width, height, mode|size-ID
$GLOBALS['TL_DCA']['tl_content']['fields']['size']['default'] = array('', '', 2);
break;
}
}
}