Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
VHS - Altersberechnung bei tx_news
<div xmlns="http://www.w3.org/1999/xhtml" lang="en"
xmlns:v="http://typo3.org/ns/FluidTYPO3/Vhs/ViewHelpers"
xmlns:f="http://typo3.org/ns/TYPO3/Fluid/ViewHelpers"
xmlns:n="http://typo3.org/ns/GeorgRinger\News\ViewHelpers"
v:schemaLocation="http://fluidtypo3.org/schemas/vhs-1.8.5.xsd">
...
<!-- Auswahl des passenden Bildes anhand des Alters der News -->
<v:variable.set name="picture" value="Grafik 1 (< 7 Tage)" />
<v:variable.set name="age">{v:math.subtract(a:'{v:system.timestamp()}',b:'{newsItem.datetime -> f:format.date(format:"U")}')}</v:variable.set>
<f:comment>Älter als 7 Tage?</f:comment>
<f:if condition="{age} > 604800">
<v:variable.set name="picture" value="Grafik 2 (> 7 Tage)" />
</f:if>
<f:comment>Älter als 30 Tage?</f:comment>
<f:if condition="{age} > 2592000">
<v:variable.set name="picture" value="Grafik 3 (> 30 Tage)" />
</f:if>
<!-- Ende der Auswahl: Bild steht nun in der Variable {picture} zur Verfügung -->
{picture}
...
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment