TypoScript Magic: tt_news Title in Headline or Menu or somewhere
Friday, June 06th, 2008 | Author: Benni
In almost every TYPO3 project of mine, I use this awesomely generic tt_news for displaying news, top offers, etc. In many projects I also have a headline or a breadcrums menu somewhere, telling about the title of the page. tt_news itself offers the possibility to substitute the page title in the <title> tag, however I often use my own title tag rendering, or by using the excellent seo_basics extension :). So the tt_news title is not substituted at all. Therefore I always wrote this little TypoScript snippet that I can use everywhere:
lib.newstitle = RECORDS
lib.newstitle {
dontCheckPid = 1
tables = tt_news
source.data = GPvar:tx_ttnews|tt_news
conf.tt_news = TEXT
conf.tt_news.field = title
conf.tt_news.required = 1
}
This renders the tt_news title if there if there exists one. This can easily be attached to anything else in TypoScript, to a breadcrumbs menu for instance:
lib.breadcrumbs = COA
lib.breadcrumbs.10 = HMENU
lib.breadcrumbs.10 {
special = rootline
special.range = 1
1 = TMENU
1.noBlur = 1
1.NO.linkWrap = > |
}
lib.breadcrumbs.20 < lib.newstitle
lib.breadcrumbs.20.conf.tt_news.wrap = > |
And boom, there you go. Same goes for any pagetitle. The nice stdWrap option “.required = 1″ also only adds the “.wrap” option if the title is not empty.
Btw… thanks to Bob who had this issue on the typo3 tt_news newsgroup this week!


Saturday, 7. June 2008
Hi, I just found your tip in the mailing list, it’s very nice ;
by the way I think you forgot one line of code in this web page, e.g. this one :
lib.breadcrumbs.20 = RECORDS
regards,
Chris
Saturday, 7. June 2008
sorry, the correct code is :
lib.newstitle=RECORDS
Saturday, 7. June 2008
Hey Chris,
yes, you’re right, I updated that one.
Friday, 13. June 2008
Now it’s OK I guess you can delete my posts now
Thursday, 26. June 2008
Hi Benni,
I can use the lib in all kind of places. The place I want to use it in however, I cannot get it to work. I would like to use the value in a graphical header image.
So it needs to be injected in ag GIFBUILDER TEXT object. And the object accepts lots of stuff, except the lib.newstitle.
Saturday, 28. June 2008
Hey Michiel.
As I told you over PM, quite simple:
GIFBUILDER.TEXT.text = blabla
works. .text here has a stdWrap feature included. However, the lib.newstitle is a separate CObject (it’s a COA), not a stdWrap. BUT stdWrap allows you to fill the stdWrap content with a cObject. Do this.
GIFBUILDER.TEXT.text.cObject < lib.newstitle
Saturday, 19. July 2008
is it possible to do the same but with the news category dynamicaly?
i can’t manage to get the news cat.
Thanks in advance for any tip.
Sunday, 21. September 2008
Hey Antonio,
yeah, possible, but then I’d suggest looking into the CONTENT object, with the select. TypoScript object, you can do a DB query with a JOIN (with the tt_news_category, the MM table and the tt_news table). Don’t know it from the top of my head, but it’s quite straightforward, I use a similar approach (tt_address and tt_addressgroups) for a couple of my sites.