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
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
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:
Quote:
<div class="field reference">
<div class="label">Reference</div>
<div class="value">
www.eagles.com</div>
</div>
but not for a date field:
Quote:
<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:
Quote:
<?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.
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).
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.
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.
Re: Dates not formatted in FE
Quote:
Originally Posted by Medianomaly
Thanks Medianomaly. Although thyon has given me a simpler solution that resource will enable me to understand how Catalog works.