[TYPO3-english] Pt #2: How to position a custom page title tag near the top of my head section?

Jigal van Hemert jigal at xs4all.nl
Thu Jun 30 09:14:02 CEST 2011


Hi,

On 30-6-2011 0:50, Markus Kobligk wrote:
> In line 1191 (refering to 4.5.3) is an XCLASS definition for this class,
> so you should be able to extend this class via XCLASS and overwrite the
> function renderContentWithHeader(). There you can change the order of

Instead of an ugly XCLASS there is a nice hook you could use:
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_pagerenderer.php']['render-postProcess']

Look at t3lib_PageRenderer::render() for details about this hook. It 
gives you an array with references to all the parts of the page, 
including the headTag property which normally contains '<head>'. There 
you can add your title tag to the very top of the head section.
(Only add the hook when you're in FE mode...)

Now you just have to see how you use the way 
TSpagegen::renderContentWithHeader() generates the page title:

	// Title
$titleTagContent = 
$GLOBALS['TSFE']->tmpl->printTitle($GLOBALS['TSFE']->altPageTitle ? 
$GLOBALS['TSFE']->altPageTitle : $GLOBALS['TSFE']->page['title'], 
$GLOBALS['TSFE']->config['config']['noPageTitle'], 
$GLOBALS['TSFE']->config['config']['pageTitleFirst']);
if ($GLOBALS['TSFE']->config['config']['titleTagFunction']) {
	$titleTagContent = 
$GLOBALS['TSFE']->cObj->callUserFunction($GLOBALS['TSFE']->config['config']['titleTagFunction'], 
array (), $titleTagContent);
}

if (strlen($titleTagContent) && 
intval($GLOBALS['TSFE']->config['config']['noPageTitle']) !== 2) {
	$pageRenderer->setTitle($titleTagContent);
}

It looks like this code can be used almost anywhere in the FE as long as 
the data in TSFE has already been generated.


-- 
Kind regards / met vriendelijke groet,

Jigal van Hemert.


More information about the TYPO3-english mailing list