2

I would like to set a checkbox in the backend to default checked.

In my case it is the field showinpreview in the file /typo3conf/ext/news/Configuration/TCA/tx_news_domain_model_media.php.

I changed the value default to 1, but it has no effect:

'showinpreview' => [
            'exclude' => 1,
            'label' => $ll . 'tx_news_domain_model_media.showinpreview',
            'config' => [
                'type' => 'check',
                'default' => 1
            ]
        ],

When I check the TCA File of tt_content for a checked checkbox it looks like this:

'sectionIndex' => [
    'exclude' => 1,
    'label' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:sectionIndex',
    'config' => [
        'type' => 'check',
        'default' => 1,
        'items' => [
            '1' => [
                '0' => 'LLL:EXT:lang/locallang_core.xlf:labels.enabled'
            ]
        ]
    ]
],

The only difference I see is the items. But I do not really understand what this item-value does.

nbar
  • 6,028
  • 2
  • 24
  • 65

3 Answers3

4

The easiest way to change this value is by overriding TCA with some pageTS. Add following to the pagets of the folder that holds the news records.

TCAdefaults.sys_file_reference.showinpreview = 1

See https://docs.typo3.org/typo3cms/TSconfigReference/PageTsconfig/TCEform/Index.html

For the older EXT:news versions use: TCAdefaults.tx_news_domain_model_media.showinpreview = 1

minifranske
  • 1,295
  • 6
  • 12
  • Oh thats nice to know! Any way I can use this in "normal" Typoscript setup(file) or extTables of my template rather then use it in the pageTS for every page with news on it? – nbar Sep 15 '16 at 13:32
  • You can include default page TS in your site package extension. This way, you can avoid including it into every page. – pgampe Sep 15 '16 at 20:08
1

Just checked - this works for me

'checkbox' => array(
        'exclude' => 0,
        'label' => 'My Label',
        'config' => array(
            'type' => 'check',
            'default' => '1'
        )
    ),
bschauer
  • 958
  • 9
  • 33
  • Thanks, I checked it somewhere else now too. Looks like its a specific problem for the field showinpreview of the news Media file. – nbar Sep 13 '16 at 14:27
1

The value of the field showinpreview is set in news/Configuration/TCA/Overrides/sys_file_reference.php. Apply your change there, and you will be happy.

But be aware: after updating of the news extension your change will be lost.

andreas
  • 16,357
  • 12
  • 72
  • 76
Stefan Padberg
  • 505
  • 2
  • 17
  • Oh wow I totaly missed that. Thanks. (I checked the original sys_file_reference for this field). Would it also be possible to set the default for `sys_language_uid` to `-1` in this file? It says $**new**SysFileReferenceColumns, so I guess I can not just copy the `sys_language_uid` from the original and change the default here? – nbar Sep 13 '16 at 15:35
  • Don't change the original extension code. As mentioned the changes will be lost after extension update. – minifranske Sep 14 '16 at 18:19
  • This is definitely not **not** the best answer. Never change the code if it is not your own. You´ll lose the possibility to update without your changes getting lost. I would also strongly recommend to use @minifranske 's approach and go for PageTSconfig. – Ralf Merz Feb 02 '17 at 14:43