[TYPO3-dev] change RTE CSS depending on tt_content:layout

Stefan Franke stefan.franke at gmx.co.uk
Wed Jan 15 11:07:22 CET 2014


Hello,
I'm working on a solution to change the RTE CSS file depending on the value of the field 'layout' in my content element in the T3 backend. In my page tsconfig I put the following userFunc-condition:

~~~tsconfig~~~~~~~~~~~~~~~~~~~~~~~~~~~~~>>>
[userFunc = user_layout()]
RTE.default.contentCSS = fileadmin/templates/css/rte_layout_tagcloud.css
[global]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<<<

In the userFunc I'm retrieving the uid of the content element from $GLOBALS['SOBE']. With this I can select the current record from the table 'tt_content' and check the value of the field 'layout'. This all works fine, except for the quite annoying fact, that I have to press the save button TWICE in order for the changes to take place.

~~~userFunc~~~~~~~~~~~~~~~~~~~~~~~~~~~~~>>>
<?php

function user_layout() {

    $value = $GLOBALS['SOBE']->editconf['tt_content'];

    // are we editing a content element?
    if (!$value) {
        return false;
    }
    
    // retrieve uid of content element
    $uid = array_shift(explode(',', key($value)));

    // get tt_content record
    $row = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('*', 'tt_content', 'uid = ' . $uid);
    
    // check layout
    switch($row['layout']) {
        // tag cloud
        case 101:
            return true;
            break;
        // everything else
        default:
            return false;
    }

}

?>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<<<

Is there any way of making this work with just one click on the 'save'-button? Or is there an even easier solution (e.g. without userFunc) to this problem?

Thanks for your help!

Kind regards,
Stefan



More information about the TYPO3-dev mailing list