Results 1 to 7 of 7

Thread: Dates not formatted in FE

  1. #1
    User
    Join Date
    01-22-10.
    Location
    Trowbridge, UK
    Posts
    61

    Default Dates not formatted in FE

    I've defined a field Date Seen as type date
    [attachment=1:2rthy5du]table date field.jpg[/attachment:2rthy5du]

    It displays OK in the BE (e.g. 2010-02-14) but in the FE it is just a number
    [attachment=0:2rthy5du]form date view.jpg[/attachment:2rthy5du]

    Could someone please tell me how to format it in the FE.

    Many thanks

  2. #2
    Experienced user
    Join Date
    08-21-09.
    Posts
    563

    Default Re: Dates not formatted in FE

    That number is actually a timestamp. You should be able to get it in the format you need by passing it through PHP's date function:

    http://php.net/manual/en/function.date.php
    Brian

  3. #3
    User
    Join Date
    01-22-10.
    Location
    Trowbridge, UK
    Posts
    61

    Default Re: Dates not formatted in FE

    Quote Originally Posted by Medianomaly
    That number is actually a timestamp. You should be able to get it in the format you need by passing it through PHP's date function
    Thanks Medianomaly. I'm using Catalog Extension so I was presuming it checked for type and converted as required. It's doing that for a URL field:
    <div class="field reference">
    <div class="label">Reference</div>
    <div class="value">www.eagles.com</div>
    </div>
    but not for a date field:
    <div class="field date_seen">
    <div class="label">Date Seen</div>
    <div class="value">1264723200</div>
    </div>
    catalog_simple.tpl code just seems to loop extracting labels and values:
    <?php foreach ($this->entries as $entry): ?>
    <div class="item<?php echo $entry['class'] ? ' '.$entry['class'] : ''; ?>">
    <?php foreach ($entry['data'] as $field=>$data): ?>
    <?php if (!in_array($field, array('catalog_name','parentJumpTo'))): ?>
    <div class="field <?php echo $field; ?>">
    <div class="label"><?php echo $data['label']; ?></div>
    <div class="value"><?php echo $data['value']; ?></div>
    </div>
    <?php endif; ?>
    <?php endforeach; ?>
    So where is $data set? I would hazard a guess that the code is in ModuleCatalog.php but I can't see where.

  4. #4
    Experienced user
    Join Date
    08-21-09.
    Posts
    563

    Default Re: Dates not formatted in FE

    This is a good resource for working with Catalog templates:
    http://dev.typolight.org/wiki/typolight ... alsCatalog

    Among other things, it will show you how to "get to" the variables you need (including your date).
    Brian

  5. #5
    Experienced user
    Join Date
    06-10-09.
    Location
    Cape Town, South Africa
    Posts
    1,387

    Default Re: Dates not formatted in FE

    you don't need that, of course DATE formatting is included, you just didn't click the format checkbox to open up the format section, selected the format type as [date] and enter the date format string, e.g. Y-m-d.

  6. #6
    User
    Join Date
    01-22-10.
    Location
    Trowbridge, UK
    Posts
    61

    Default Re: Dates not formatted in FE

    Brilliant!

    Thanks thyon. I thought that only impacted the BE but I see it also effects the FE.

    I did lookup sprintf but that was showing things like %02d/%02d/%02d which didn't work when Y-m-d is so simple!

    Now to solve my other date problem with the form input.

  7. #7
    User
    Join Date
    01-22-10.
    Location
    Trowbridge, UK
    Posts
    61

    Default Re: Dates not formatted in FE

    Quote Originally Posted by Medianomaly
    This is a good resource for working with Catalog templates:
    http://dev.typolight.org/wiki/typolight ... alsCatalog

    Among other things, it will show you how to "get to" the variables you need (including your date).
    Thanks Medianomaly. Although thyon has given me a simpler solution that resource will enable me to understand how Catalog works.

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
  •