[TYPO3-dev] Re: Hook into page title generation

Philipp philippwrann at gmx.at
Thu Jul 11 17:37:45 CEST 2013


okay,  finally did it - kinda easy if you know it...

<?php

namespace Pixelpoint\Donau\UserFunc;

/**
 * Description of ContentPostProc
 * This is used to run post processes on sourcecodes
 *
 * @author Philipp Wrann
 * @vendor Pixelpoint
 */
class ContentPostProc implements \TYPO3\CMS\Core\SingletonInterface {
	
	/**
	 * Alter the title tag
	 * If a subtitle is stored for the current page object we use this (and only this) as title for the page
	 * If no subtitle is set we use the page title plus the website title (appended)
	 * 
	 * @param \array $params
	 * @param \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController $pObj
	 * @return void
	 */
	public function alterTitleTag(&$params, &$pObj) {
		if ($pObj->page['subtitle'] != '') {
			$pObj->content = preg_replace("/(<title>)(.*?)(<\/title>)/", "$1".$pObj->page['subtitle']."$3",$pObj->content);
		} else {
			$pObj->content = preg_replace("/(<title>)(.*?)(<\/title>)/", "$1".$pObj->page['title']." - ".$pObj->tmpl->setup['sitetitle']."$3",$pObj->content);
		}
	}
	
}

?>



More information about the TYPO3-dev mailing list