heimrichhannot/contao-be_hyperlink

This bundle offers a simple backend hyperlink form field (text link or button).

2.0.2 2021-04-15 15:08 UTC

This package is not auto-updated.

Last update: 2024-11-10 02:00:09 UTC


README

Latest Stable Version Total Downloads Travis Coveralls github

This bundle offers a simple backend hyperlink form field (text link or button).

For Contao 3 compability check out the contao-3 branch.

Requirements

  • Contao 4 (only tested with 4.4 LTS)
  • PHP7 (only tested with PHP ^7.1)

Technical instructions

Just add the field to some of your data container arrays as follows:

$GLOBALS['TL_DCA']['tl_*']['fields']['myHyperlink'] = array
(
    'label'     => &$GLOBALS['TL_LANG']['tl_*']['myHyperlink'],
    'inputType' => 'hyperlink',
    'eval'      => array(
        'text' => &$GLOBALS['TL_LANG']['tl_*']['myHyperlinkText'], // string
        'linkClass'    => 'tl_submit', // use this for contao's button styling
        'tl_class' => 'long',
        'target' => '_blank',
        // the url can be specified as string, callback array ora callable function
        'url'      => 'http://www.example.org',
        'url'      => ['MyClass', 'getUrl'],
        'url'      => function(\DataContainer $objDc) {
            return sprintf('http://www.example.org?id=%s', $objDc->id);
        }
    )
);