PHP code example of heimrichhannot / contao-dc-multilingual-utils-bundle

1. Go to this page and download the library: Download heimrichhannot/contao-dc-multilingual-utils-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-dc-multilingual-utils-bundle example snippets


/**
 * @Hook("loadDataContainer")
 */
class LoadDataContainerListener
{
    private DcMultilingualUtil $multilingualUtil;

    public function __invoke(string $table): void
    {
        if ('tl_content' === $table) {
            $this->multilingualUtil->addDcMultilingualSupport(
                $table, ['de', 'en', 'pl'], 'de', [ 'text', 'rsce_data' ] 
            );
        }
    }
}

/**
 * @Hook("loadDataContainer")
 */
class LoadDataContainerListener
{
    private DcMultilingualUtil $multilingualUtil;

    public function __invoke(string $table): void
    {
        if ('tl_content' === $table) {
            $this->multilingualUtil->addDcMultilingualSupport(
                $table, // Table name
                ['de', 'en', 'pl'], // Supported languages
                'de', // Fallback language
                [ // the translatable fields
                    'text', // add fields here...
                    'rsce_data' // add this if you have rocksolid custom elements (tl_content only)
                ],
                [ // options
                    'langColumnName', // the language field in the dca's records (you have a record for every language and this column holds which one it is)
                    'langPid', // this field holds the parent record of every translated record
                ]
            );
            break;
        }
    }
}