I thought that developers might want to use this example I created, as it's a really kewl overlooked feature in Contao.
In the example below I create a non-database field, to use as a help rendering in a section above some of the fields. You have to add the field into the normal palette, but it's callback is used to render it, without any DB activity. You can then add text/html into language strings and pull it all in at runtime. I added text, styles, and an icon to illustrate.
[attachment=0:9riektkt]dcahelp.jpg[/attachment:9riektkt]
Code:
$GLOBALS['TL_DCA']['tl_calendar_events']['fields']['helpmode'] = array
(
'input_field_callback' => array('tl_calendar_invites', 'helpMode')
);
class tl_calendar_invites extends \Backend
public function helpMode(\DataContainer $dc, $xlabel)
{
$icon = $this->generateImage('show.gif', $GLOBALS['TL_LANG']['tl_calendar_events']['helpmode'][0], ' style="vertical-align:-4px"');
return '<div class="long">
<h3><label style="color:#8ab858">'.$icon. ' ' . $GLOBALS['TL_LANG']['tl_calendar_events']['helpmode'][0].'</label></h3>
<div class="">'.$GLOBALS['TL_LANG']['tl_calendar_events']['helpmode'][1].'</div>
</div>';
}
…
}
Bookmarks