Search code examples
typo3-tca

How can i make a Link input Field in TCA


I need the same function like the TYPO3 standard. There you can choose a link (external Site, internal Site, File, etc.)

How can I do this?


Solution

  • You can find the TCA for the TYPO3 backend in the files typo3/sysext/cms/tbl_tt_content.php and typo3/sysext/cms/tbl_cms.php. Here you find the header_link example.

    Solution for TYPO3 6.1 and lower:

    'header_link' => array(
        'label' => 'LLL:EXT:cms/locallang_ttc.xml:header_link',
        'exclude' => 1,
        'config' => array(
            'type' => 'input',
            'size' => '50',
            'max' => '256',
            'eval' => 'trim',
            'wizards' => array(
                '_PADDING' => 2,
                'link' => array(
                    'type' => 'popup',
                    'title' => 'LLL:EXT:cms/locallang_ttc.xml:header_link_formlabel',
                    'icon' => 'link_popup.gif',
                    'script' => 'browse_links.php?mode=wizard',
                    'JSopenParams' => 'height=300,width=500,status=0,menubar=0,scrollbars=1',
                ),
            ),
            'softref' => 'typolink',
        ),
    ),
    

    Solution for TYPO3 6.2.x - 7.6.x:

    'header_link' => array(
        'label' => 'LLL:EXT:cms/locallang_ttc.xml:header_link',
        'exclude' => 1,
        'config' => array(
            'type' => 'input',
            'size' => '50',
            'max' => '256',
            'eval' => 'trim',
            'wizards' => array(
                '_PADDING' => 2,
                'link' => array(
                    'type' => 'popup',
                    'title' => 'LLL:EXT:cms/locallang_ttc.xml:header_link_formlabel',
                    'icon' => 'EXT:backend/Resources/Public/Images/FormFieldWizard/wizard_link.gif',
                    'module' => array(
                        'name' => 'wizard_element_browser',
                        'urlParameters' => array(
                            'mode' => 'wizard',
                            'act' => 'page'
                        )
                    ),
                    'JSopenParams' => 'height=300,width=500,status=0,menubar=0,scrollbars=1',
                ),
            ),
            'softref' => 'typolink',
        ),
    ),
    

    Solution for TYPO3 8.x:

    'header_link' => array(
        'label' => 'LLL:EXT:cms/locallang_ttc.xml:header_link',
        'exclude' => 1,
        'config' => array(
            'type' => 'input',
            'renderType' => 'inputLink',
        ),
    ),