Skip to content

Instantly share code, notes, and snippets.

@magicHatOfTYPO3
Last active February 22, 2016 16:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save magicHatOfTYPO3/07f577f758edb969092b to your computer and use it in GitHub Desktop.
Save magicHatOfTYPO3/07f577f758edb969092b to your computer and use it in GitHub Desktop.
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