Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
TYPO3: Hook to remove the generator meta tag (TYPO3 CMS 6.2)
<?php
namespace Your\Extension\Namespace\Hooks;
/**
* Clean up source
*/
class CleanSource extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin
{
/**
* No cache
*
* @return void
*/
public function contentPostProcOutput(&$params, &$that)
{
if (!$GLOBALS['TSFE']->isINTincScript()) {
return;
}
$this->_removeGenerator($params['pObj']->content);
}
/**
* Cached
*
* @return void
*/
public function contentPostProcAll(&$params, &$that)
{
if ($GLOBALS['TSFE']->isINTincScript()) {
return;
}
$this->_removeGenerator($params['pObj']->content);
}
/**
* Remove generator meta tag
* <meta name="generator" content="TYPO3 6.2 CMS">
*
* @return void
*/
private function _removeGenerator(&$content)
{
$content = preg_replace('/<meta name="?generator"?.+?>/is', '', $content);
}
}
<?php
// hook is called after caching (for modification of pages with COA_/USER_INT objects)
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-output'][] = 'Your\\Extension\\Namespace\\Hooks\\CleanSource->contentPostProcOutput';
// hook is called before caching (for modification of pages on their way in the cache)
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-all'][] = 'Your\\Extension\\Namespace\\Hooks\\CleanSource->contentPostProcAll';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment