[TYPO3-ttnews] Hide news if no content is shown - SOLUTION

Ralf Heydenreich rheydenr at justmail.de
Mon Jun 4 01:45:03 CEST 2012


Am 26.05.2012 17:09, schrieb Ralf Heydenreich:
> Hi all,
> I want to hide the news block if there are no news to display. Therefore
> I have defined a div tag around the news block where I can set the style
> to "display:none" (works with TemplaVoilà). Unfortunately, I don't know
> how to test if there's no content. The following solution does NOT work:
> [...]
> 

After a bunch of unsuccessful tries I've patched the tt_news code (oh
yeah!). What I've done is to insert the following line into class
tx_ttnews, function displayList near line 650:

$this->local_cObj->LOAD_REGISTER(array(
     $prefix_display . '_newsCount' => $newsCount), '');

This creates a new register for each view which contains the news count
for this view. After this, I introduced a new wrapper container for my
news container and mapped it to an attribute Typoscript Object Path (I'm
using TemplaVoilà for rendering). The TS for this wrapper div is as follows:

lib.event_hider = TEXT
lib.event_hider.value = display:none;
lib.event_hider.if.isFalse.data = register:displayLatest_newsCount


My HTML template code for this is:

<div id="block-hider" style=""> <-- this is mapped to lib.event_hider -->
	<div id="eventblock">
	  ... here comes the news content ...
	</div>
</div>


That's all. Perhaps the one line of code could be inserted into the main
branch of tt_news since I think that it could be useful for other
people, too.

Greetings,

Ralf.


More information about the TYPO3-project-tt-news mailing list