typo3, tt_news: Combination of categoryMode

105 Views Asked by At

I’d like to show news if they have the category A AND B but to NOT SHOW if the also have the category C.

Is this possible? How to configure such a combination?

Thank you!

1

There are 1 best solutions below

0
On

Note: I did this on Typo3 version 4.3.5, nut sure if it works in the same way in newer versions.

A while ago, I "flexed" tt_news into a simple listing of events (a news item acted as an event) and needed a combination of categories to show on one page and another combination on a second page. As far as I remember, doing something like this is not possible with the normal tt_news content element. Instead, I did it with constructing an SQL select with TypoScript.

Add a marker where you want the content. Let's call it "newsmarker". You have to find out the IDs of the news categories A, B, C and update the "where" part accordingly. I assumed A=1, B=2, C=3. Also change pidInList to the ID of the page where your news are stored.

The output here is just the title and the formatted date with a dash in between.

markers.newsmarker = CONTENT
markers.newsmarker {
  table = tt_news
  select {
    pidInList = 2161 # page ID where news are stored
    orderBy = datetime asc
    selectFields = uid, title, datetime, short, bodytext, category, tt_news_cat_mm.uid_foreign as fgnCat
    leftjoin = tt_news_cat_mm ON (tt_news.uid = tt_news_cat_mm.uid_local)
    where = (tt_news_cat_mm.uid_foreign = 1 AND tt_news_cat_mm.uid_foreign = 2 AND tt_news_cat_mm.uid_foreign NOT 3)
  }
  renderObj = COA
  renderObj {
    10 = TEXT
    10.field = title
    15 = TEXT
    15.value = - 
    20 = TEXT
    20.field = datetime
    20.strftime = %d.%m.%y (%H.%M)

  }
}