Home

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!

Tags » «

Trackback: Trackback-URL | Comments Feed: RSS 2.0
Category: TYPO3

You can leave a response.

11 Responses

  1. 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

  2. sorry, the correct code is :

    lib.newstitle=RECORDS

  3. Hey Chris,

    yes, you’re right, I updated that one.

  4. Now it’s OK I guess you can delete my posts now ;-)

  5. 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.

  6. 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

  7. 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.

  8. 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.

  9. Thanks for the tip. I have tried using this on my news and notices and works fine in the default language. However - upon Localization into another language - tt_news keeps default language breadcrumbs and titles. I’m a typoscript noob and was wondering if anything needs to be changed here to support multiple languages.

    Thanks

  10. You can not believe how long ive been looking for something like this. Browsed through 8 pages of Yahoo results and couldnt find anything. Very first page on Bing. There this is…. Really have to start using it more often!

  11. thx for the code, doing good :-)

Leave a Reply