PHP code example of heimrichhannot / contao-be_explanation-bundle

1. Go to this page and download the library: Download heimrichhannot/contao-be_explanation-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

heimrichhannot / contao-be_explanation-bundle example snippets


use AppBundle\EventListener\Dca\TableListener;

$GLOBALS['TL_DCA']['tl_table']['fields']['myExplanation'] = [
    'inputType' => 'explanation',
    'eval'      => [
        'text'          => &$GLOBALS['TL_LANG']['tl_table']['explanation']['myExplanation'], // this is a string, not an array
        'text_callback' => [TableListener::class, 'onTextCallback'], // a callback to dynamical generate text. Can also be a callable.
        'class'         => 'tl_info', // all contao message css classes are possible
        'tl_class'      => 'w50 long',
        'collapsible'   => true // If text is to long, if will be collapsed
    ]
];

public function textCallback(array $attributes): string {
    $dc = $attributes["dataContainer"];
    $text = $attributes["text"];
    return "My new text";
}