TYPO3

Tutorials - Howto`s - Tipps & Tricks

Tutorials \ TypoScript \ TYPO3: Jahreszahl für Copyright-Text ausgeben
Klicks: 553
TYPO3: Jahreszahl für Copyright-Text ausgeben
Von: maddesigns
Am: 09.08.2011 - 09:35

TYPO3: Jahreszahl für Copyright-Text ausgeben

Ein häufiges TYPO3 Snippet für die Ausgabe der Jahreszahl in Copyright-Texten findet man in der Form:

lib.copyright = TEXT
lib.copyright.data = date:U
lib.copyright.strftime = %Y
lib.copyright.wrap= © | typo3.org

Ein erweitertes Beispiel in der der Zeitraum in der Form "2008 - 2010" dargestellt wird, kann man wie folgt umsetzen.

Typoscript-Constants:

text {
  #Jahr der Gründung bzw. Beginn
  year = 2008
  
  #Text 
  copyright = typo3.org 
}

Typoscript-Setup:

lib.copyright = TEXT
lib.copyright {
  preCObject = TEXT
  preCObject {
    noTrimWrap = |{$text.year} - | |
    if {
      isGreaterThan.cObject = TEXT
      isGreaterThan.cObject {
        data = date:U
        strftime = %Y
      }
      value = {$text.year}
    }
  }
  data = date:U
  strftime = %Y
  dataWrap =<h5 class="copyright">|</h5>
  noTrimWrap = |&copy; | {$text.copyright}|
}

Vorteil an der Lösung ist, dass man nur einmal die Konstanten (Jahreszahl der Gründung) einrichten muss, das aktuelle Jahr wird durch TYPO3 ermittelt. Ist das Jahr gleich dem aktuellen, wird es nur einmal in der Form "© 2010 typo3.org" ausgegeben. Ist es unterschiedlich, wird es in der Form "© 2008 - 2010 typo3.org" ausgegeben. Datum und Uhrzeit

lib.datum_uhrzeit = COA_INT
lib.datum_uhrzeit {
  10 = TEXT
  10 {
    data = date:U
    # Format nach Vorbild: 12. Oktober 2010 - 21:23:02
    strftime = %e. %B %Y - %H:%M:%S
  }
}
Spenden Sie dem Autor dieses Tutorials ein kleinen Betrag für seine Mühe!

Kommentare

To top TYPO3 - Tutorials - Howto`s - Tipps & Tricks