2

I made a custom marker for tt_news which shows the first image from the media field, OR the third if it belongs to certain category (lets say category with ID = 2). I dont know how to make that conditional. This is what I have so far:

    10 = IMAGE
    10.file{
        width = 550
        height = 350
        import = uploads/pics/
        import{
            field = image
            listNum = 0

            #If also belongs to the category "Startseite", the listNum should be 2
            listNum.stdWrap.override = TEXT
            listNum.stdWrap.override{
                value = 0
                if{
                    #??????
                }
            }
        }
    }
Enrique Moreno Tent
  • 24,127
  • 34
  • 104
  • 189
  • Categories and news records are mm-related, so maybe you can't solve this with pure typoscript. But with the help of a `userFunc` this should be fairly easy. – Mateng Apr 17 '12 at 09:24

1 Answers1

1

You need to write custom condition as described in doc in userFunc section (bottom)

http://typo3.org/documentation/document-library/core-documentation/doc_core_tsref/4.3.2/view/1/4/

News and categories are connected with MM relation so you just to check if MM table contains this pair...

typo3conf/localconf.php:

function user_newsInCategory($catUid) {
    $ttNewsGet = (t3lib_div::_GP('tx_ttnews'));
    $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
        'uid_foreign',
        'tt_news_cat_mm',
        'uid_foreign = ' . $catUid . ' AND uid_local=' . intval($ttNewsGet['tt_news'])
    );
    return ($GLOBALS['TYPO3_DB']->sql_num_rows($res) > 0) ? true : false;
} 

somwhere in TS after your 10 = IMAGE { ... } block:

[userFunc = user_newsInCategory(2)]
    10.file.import.listNum = 2
[end]

edit:

As you can see in the sample it works only if news is displayed (ie. if param &tx_ttnews[tt_news] exists in URL)

To check similar check per each list item you need to use custom marker via hook (as described in tt_news manual) by using extraItemMarkerProcessor - then you can use similar condition per each $row to display different images.

biesior
  • 55,576
  • 10
  • 125
  • 182