Hey,

so oft wünsche ich mir beim Textelement einen separaten Link/Button einbinden zu können. Oder das gesamte Element sollte verlinkt werden. Daher hab ich nun endlich eine DCA-Anpassung dafür gemacht, die ihr euch gerne übernehmen könnt:

Contao 4.9.x: ggf. Ordnerstruktur anlegen, falls nicht vorhanden:

DCA-Felder:
contao/dca/tl_content.php
Code:
<?php

use Contao\CoreBundle\DataContainer\PaletteManipulator;

PaletteManipulator::create()
    ->addLegend('link_legend', 'image_legend', PaletteManipulator::POSITION_AFTER)
    ->addField('button_linkurl', 'link_legend', PaletteManipulator::POSITION_APPEND)
    ->addField('button_linktitle', 'link_legend', PaletteManipulator::POSITION_APPEND)
    ->addField('link_all', 'link_legend', PaletteManipulator::POSITION_APPEND)
    ->applyToPalette('text', 'tl_content')
;

/**
 * Fields
 */
$GLOBALS['TL_DCA']['tl_content']['fields']['button_linkurl'] = [
    'label'     => &$GLOBALS['TL_LANG']['tl_content']['button_linkurl'],
    'exclude'   => true,
    'inputType'               => 'text',
    'eval'                    => array('mandatory'=>false, 'rgxp'=>'url', 'decodeEntities'=>true, 'maxlength'=>255, 'dcaPicker'=>true, 'addWizardClass'=>false, 'tl_class'=>'w50'),
    'sql'       => "varchar(255) NOT NULL default ''",
];
$GLOBALS['TL_DCA']['tl_content']['fields']['button_linktitle'] = [
    'label'     => &$GLOBALS['TL_LANG']['tl_content']['button_linktitle'],
    'exclude'   => true,
    'inputType' => 'text',
    'eval'      => ['maxlength' => 255, 'tl_class' => 'w50 clr'],
    'sql'       => "varchar(255) NOT NULL default ''",
];
$GLOBALS['TL_DCA']['tl_content']['fields']['link_all'] = [
    'label'     => &$GLOBALS['TL_LANG']['tl_content']['link_all'],
    'exclude'   => true,
    'inputType' => 'checkbox',
    'eval'      => ['tl_class' => 'w50'],
    'sql'       => "varchar(255) NOT NULL default ''",
];
Sprach-Labels:
contao/languages/de/tl_content.php
Code:
<?php
$GLOBALS['TL_LANG']['tl_content']['link_legend'] = 'Link-Einstellungen';

$GLOBALS['TL_LANG']['tl_content']['button_linkurl'][0] 		= 'Link-URL';
$GLOBALS['TL_LANG']['tl_content']['button_linkurl'][1]		= 'Linkziel, intern oder mit https://';

$GLOBALS['TL_LANG']['tl_content']['button_linktitle'][0] 		= 'Link-Bezeichnung';
$GLOBALS['TL_LANG']['tl_content']['button_linktitle'][1]		= 'Der Text, der verlinkt wird';

$GLOBALS['TL_LANG']['tl_content']['link_all'][0] 		= 'Gesamtes Element verlinken';
$GLOBALS['TL_LANG']['tl_content']['link_all'][1]		= 'Der Link erstreckt sich über das gesamte Element';