[TYPO3-ttnews] How to test if a list is empty, from TypoScript
Olivier Schopfer
ops at wcc-coe.org
Wed Sep 5 13:15:55 CEST 2007
Olivier Schopfer wrote:
> Hi there,
>
> I'm looking for a way to test if a LATEST list is empty, in order to
> automatically adapt the layout of the page (=hide all the COA).
>
> The if condition below doesn't work. Does anybody have an idea of how to
> make if work?
>
> Olivier
> ops at wcc-coe.org
>
Hi again,
I found the solution to my own problem. Here it is, for anyone interested:
I had the idea of using a typoscript register, to count the news items
from the list that tt_news is about to render.
To do so, I used one of the stdWraps, and added a cObject to it, with
LOAD_REGISTER:
newsList < plugin.tt_news
newsList {
(... various news settings)
# Count the news items
displayLatest.subheader_stdWrap.cObject = COA
displayLatest.subheader_stdWrap.cObject {
10 = TEXT
10.current = 1
20 = LOAD_REGISTER
20.news_count.cObject = TEXT
20.news_count.cObject.data = register:news_count
20.news_count.cObject.wrap = |+1
20.news_count.prioriCalc = intval
}
}
Item 10 is to render the normal content (here the subheader).
Item 20 doesn't produce any output, but increments the counter stored in
register:news_count
The news list item is mapped as a TemplaVoila field.
I then use another typoscript based TemplaVoila field, that is
calculated AFTER the first one (very important), but with a result
mapped to the style attribute of the main div containing the list.
10 = TEXT
10.value = display:none;
10.if.isFalse.data = register:events_count
This results in a div tag like this, when there is no news in the list:
<div id="news-bloc style="display:none;">
So the whole block is hidden.
Hope this helps. And maybe someone will find a simpler solution...
Olivier
More information about the TYPO3-project-tt-news
mailing list