Results 1 to 4 of 4

Thread: Shorten day name to 3 letters

  1. #1
    User
    Join Date
    06-19-09.
    Posts
    106

    Default Shorten day name to 3 letters

    Hi, I would like to shorten the day names in the event teaser to 3 letters, e.g. Sun instead of Sunday.

    The event_teaser.html5 template has this code to output the day:

    <?php echo $this->firstDay; ?>

    Could someone let me know what to do to shorten the day names? Many thanks.

  2. #2
    User Andreas's Avatar
    Join Date
    07-11-09.
    Location
    Mönchengladbach
    Posts
    499

    Default

    You can try to do it with your system/langconfig.php
    PHP Code:
    $GLOBALS['TL_LANG']['DAYS'][0] = 'Sonntag';
    $GLOBALS['TL_LANG']['DAYS'][1] = 'Montag';
    $GLOBALS['TL_LANG']['DAYS'][2] = 'Dienstag';
    $GLOBALS['TL_LANG']['DAYS'][3] = 'Mittwoch';
    $GLOBALS['TL_LANG']['DAYS'][4] = 'Donnerstag';
    $GLOBALS['TL_LANG']['DAYS'][5] = 'Freitag';
    $GLOBALS['TL_LANG']['DAYS'][6] = 'Samstag'
    Or with PHP in your template
    PHP Code:
    <?php echo substr($this->firstDay03); ?>
    http://de1.php.net/manual/de/function.substr.php
    Web-Development, Freelancer, Burgtech, XHTML, HTML5, CSS, PHP, Javascript, MooTools, MySQL and more
    Amazon wishlist

  3. #3
    Community-Moderator lucina's Avatar
    Join Date
    10-08-10.
    Location
    Issy-les-moulineaux
    Posts
    93

    Default

    Or use the appropriate PHP function:

    PHP Code:
    <span class="weekday"><?php echo $this->parseDate("D"$this->startDate); ?></span> 
    ...

  4. #4
    User Andreas's Avatar
    Join Date
    07-11-09.
    Location
    Mönchengladbach
    Posts
    499

    Default

    Quote Originally Posted by lucina View Post
    Or use the appropriate PHP function:
    Ok this works in english but not e.g. for german. That depends on the fact that PHP date() only outputs in english and Contao method Date::parse() transforms it to other languages.

    If you have a language that didn't output the desired length you have to modify this:
    PHP Code:
    $GLOBALS['TL_LANG']['DAYS_SHORT'][0] = 'So';
    $GLOBALS['TL_LANG']['DAYS_SHORT'][1] = 'Mo';
    $GLOBALS['TL_LANG']['DAYS_SHORT'][2] = 'Di';
    $GLOBALS['TL_LANG']['DAYS_SHORT'][3] = 'Mi';
    $GLOBALS['TL_LANG']['DAYS_SHORT'][4] = 'Do';
    $GLOBALS['TL_LANG']['DAYS_SHORT'][5] = 'Fr';
    $GLOBALS['TL_LANG']['DAYS_SHORT'][6] = 'Sa'
    New method for $this->parseDate() is Date::parse().
    Web-Development, Freelancer, Burgtech, XHTML, HTML5, CSS, PHP, Javascript, MooTools, MySQL and more
    Amazon wishlist

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •