[TYPO3-dev] Changing backend CSS only for BE users of a certain group.
Steffen Müller
typo3 at t3node.com
Thu Mar 31 12:20:51 CEST 2011
Hi.
On 31.03.2011 10:51 Steffen Kamper wrote:
> Am 31.03.2011 10:25, schrieb Steffen Gebert:
>>
>> You could use the addCssFile() method of the PageRenderer or the
>> addStyleSheet(Directory)() methods of the template class.
>> I would prefer this way instead of adding the skin during runtime (maybe
>> personal taste..)
>>
>
> i would use the constructPostProcess hook of backend.php.
> Look to ext beuserswitch for an example.
Perfect. The solution to my problem looks like this:
ext_tables.php:
if (TYPO3_MODE == 'BE') {
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/backend.php']['constructPostProcess'][]
= 'EXT:my_skin/classes/class.tx_myskin_hook.php:tx_myskin_hook->addStyles';
}
classes/class.tx_myskin_hook.php:
class tx_myskin_hook {
public function addStyles($conf, $pObj) {
$pageRenderer = $GLOBALS['TBE_TEMPLATE']->getPageRenderer();
$cssPath = t3lib_extMgm::extRelPath('my_skin') . 'res/css/';
$extConf =
unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['my_skin']);
$allowedGroups = t3lib_div::trimExplode(',', $extConf['beGroups'],
TRUE);
$userGroups = t3lib_div::trimExplode(',',
$GLOBALS['BE_USER']->user['usergroup']);
$matchingGroups = array_intersect($userGroups, $allowedGroups);
if (!empty($matchingGroups)) {
$pageRenderer->addCssFile($cssPath . 'my_skin.css');
}
}
}
It seems, the BE code structure is much cleaner than I expected. Good work!
--
cheers,
Steffen
TYPO3 Blog: http://www.t3node.com/
Twitter: http://twitter.com/t3node
More information about the TYPO3-dev
mailing list