0
votes

I have a lot of news items with different categories. Code below works, but it wraps titles of all news in the same way.

plugin.tt_news.displayList {
    title_stdWrap.wrap = <div class="my-class">|</div>
    title_stdWrap.insertData = 1
}

I need to wrap title depending on the category of the news item. Something like this (pseudo-code):

plugin.tt_news.displayList {

    if (category == 1):
        title_stdWrap.wrap = <div class="special-class">|</div>
    else:
        title_stdWrap.wrap = <div class="my-class">|</div>

    title_stdWrap.insertData = 1
}
2

2 Answers

0
votes

If you can put your category into a global variable or global string (somewhere in the $GLOBALS array, perhaps), you could use globalVar or globalString. See Conditions for syntax.

0
votes

I can not test now this because I usually use the extension news instead of tt_news, but this snippet may could help. You can use a CASE object and you can use a register to handle the category uid for the "current" record.

plugin.tt_news.displayList {
    title_stdWrap.wrap = CASE
    title_stdWrap.wrap {
        key.data = register:newsCategoryUid

        default = TEXT
        default.value = <div class="my-class">|</div>

        1 = TEXT
        1 = <div class="special-class">|</div>
    }
    title_stdWrap.insertData = 1
}

See here also an example which describe a similar request as yours: Different wraps