TYPO3 / tt_news – use news title as page title in multilanguage environment

If you are using the popular extension “tt_news”, you probably want the news title as page title on the single view of the news entries. Especially for SEO and sharing (Facebook, Twitter,…) it is very useful to have this information in the TITLE – tag of the page.

All you have to do is to overwrite the default page title with the custom news title – but it is tricky if you want this behaviour for all configured languages on your page!

I’ll simply post my typoscript configuration here with some comments – if you have further questions, feel free to post them…


#######################

### first check, if we have a news id in the querystring
[globalVar = GP:tx_ttnews|tt_news > 0]

lib.newstitle = CONTENT
lib.newstitle {
table = tt_news
select {
selectFields = title
languageField = sys_language_uid

# id(s) of the page with the tt_news records

pidInList = 120,121
andWhere {

# grab the querystring vars and assign it to uid

data = GP:tx_ttnews|tt_news
wrap = uid = |
}

# define the language

languageField = sys_language_uid

}
renderObj = COA
renderObj {
10 = TEXT
10.field = title
}
}
[global]

Now we have a typoscript object named “lib.newstitle” containing the title
of the current displayed news entry. But CAUTION: this works for the default language only, if we want additional languages, we have to alter the select statement to use the “l18n_parent” id for the given data item:


[globalVar = GP : L = 1,GP : L = 2, ...]
lib.newstitle.select.andWhere.wrap = l18n_parent = |
[global]

Just insert all you configured language ids.
Finally, we have to assign the “lib.newstitle” string to our page (assuming, that our title is configured in page.headerData.10) :


[globalVar = GP:tx_ttnews|tt_news > 0]
page.headerData.10 >
page.headerData.10 = COA
page.headerData.10 < lib.newstitle page.headerData.10.wrap = My fancy typo3 website ::  |
[global]

That’s it – hopefully, this will save some time for you…

1 thought on “TYPO3 / tt_news – use news title as page title in multilanguage environment

  1. Ramdhani

    Danke für den Tipp. Hab auch etwas für euch Noch ein aetekllus Problem mit tt_news ist die Anbindung an perfectlightbox. Die Lightbox zeigt immer nur den ersten Bildtitel an. Folgendes TypoScript hat bisher geholfen:plugin.tt_news.imageMarkerFunc = tx_perfectlightbox->ttnewsImageMarkerFuncDie aktuelle Versionen sorgen jedoch dafür dass keine Bilder mehr angezeigt werden. Lösung:plugin.tt_news.imageMarkerFunc = tx_perfectlightbox->user_ImageMarkerFuncWeiterhin viel Spaß mit Typo3

Leave a Reply

Your email address will not be published. Required fields are marked *