Developer
Hook: change the classes
Before the body tag is rendered, the hook pageclasses gets all
collected classes and may add, change or remove them. The array is passed by
reference, keys and values are the (HTML-escaped) class names.
Register the hook in the ext_localconf.php of your extension:
EXT:my_extension/ext_localconf.php
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['pageclasses']['pageclassesCssHook'][]
= \MyVendor\MyExtension\Hook\PageclassesHook::class;
Copied!
EXT:my_extension/Classes/Hook/PageclassesHook.php
namespace MyVendor\MyExtension\Hook;
class PageclassesHook
{
/**
* @param object $parentObject the plugin \SvenT\Pageclasses\Plugin\Pageclasses
* @param array<string, string> $pageClasses
*/
public function processPageclassesCssHook($parentObject, array &$pageClasses): void
{
$pageClasses['is-christmas'] = 'is-christmas';
}
}
Copied!
TypoScript
The body tag is rendered by the USER object plugin.
(class
\Sven, method main). It returns
the complete body tag, e.g. <body class="home layout_, or <body> if
there is no class.