[Typo3] Dynamic page title
Charles Rector
crector at iexposure.com
Mon Jun 27 17:49:55 CEST 2005
Through experimentation, I figured out how to do this by modifying the
mf_pagetitle extension myself.
Here's what I came up with:
class user_pagetitle_class {
var $cObj;
function changetitle ($content, $conf) {
$ttnews = t3lib_div::_GP('tx_ttnews');
$result =
$GLOBALS["TSFE"]->tmpl->setup["plugin."]["mf_pagetitle."]["title"];
if ($ttnews) {
$ttnews = $ttnews['tt_news'];
$ttnews_res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('title',
'tt_news', 'uid='.$ttnews);
$ttnews_row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($ttnews_res);
$result = str_replace ("{tt_news:title}", $ttnews_row['title'], $result);
}
$result = str_replace ("{page:title}",
$GLOBALS['TSFE']->page["title"], $result);
return $result;
}
}
So now, for example, I can do this in my typoscript:
includeLibs.pagetitle = typo3conf/ext/mf_pagetitle/pagetitle.php
plugin.mf_pagetitle.title = Summary - {tt_news:title}
config.titleTagFunction = user_pagetitle_class->changetitle
And have the page title show up like this in the HTML, for example:
<title>Summary - My Test Article Title</title>
This is when I am viewing the "SINGLE" view for example, and it passes
tx_ttnews[tt_news]=123 on the URL.
Dunno if this is the proper way to go about it, but it seems to work!
Charles Rector wrote:
> I have installed the "Page Title Changer" extension, but I can't figure
> out how to dynamically look up the title for my page.
>
> Right now, I'm just trying:
>
>
> includeLibs.pagetitle = typo3conf/ext/mf_pagetitle/pagetitle.php
>
> plugin.mf_pagetitle.title = Summary - {DB:tt_news:468:title}
>
> config.titleTagFunction = user_pagetitle_class->changetitle
>
>
> But I just get the literal text "Summary - {DB:tt_news:468:title}" as my
> page title. Ultimately, I want to be able to also specify a dynamic
> record pid isntead of 468.
>
> Can someone help me to do this?
More information about the TYPO3-english
mailing list