format timestamp in 'headerFields'

How to develop custom Contao extensions

format timestamp in 'headerFields'

Postby synergie » Tue Feb 09, 2010 12:09 pm

Hello,

I have some headerFields that I display very well. My only problem is that I have a unixtimestamp that I whant to display as hour and minutes (like 13:05), but my_timestamp is displayed as "unixtimestamp" so just an integer.

How and where can I format "my_timestamp" to Date? It is normally simple like
Code: Select all
date("H:m",$my_timestamp)
but I don't know where to write this code. I try to use "group_callback"(http://www.typolight.org/callbacks.html) but it will be working only in version 2.8 of Typolight !


Code: Select all
// List
'list' => array
(
'sorting' => array
(
'mode' => 4,
'fields' => array('is_ok'),
'headerFields' => array('my_description', 'my_timestamp''),
'flag' => 5,
'panelLayout' => 'sort,search,limit',
'child_record_callback' => array('tl_test', 'list_test')
),

Thanks for help
User avatar
synergie
User
 
Posts: 41
Joined: Mon Nov 23, 2009 2:27 pm
Location: Valais, Switzerland

Re: format timestamp in 'headerFields'

Postby Toflar » Mon Feb 15, 2010 11:31 pm

There was a ticket about this. I'm sorry for you but you will need to update to 2.8 anyway because it'll be fixed as from 2.8 on only...:)

Ticket: http://dev.typolight.org/issues/show/1540
Revision: http://dev.typolight.org/repositories/r ... olight/169
User avatar
Toflar
User
 
Posts: 96
Joined: Fri Jun 19, 2009 5:30 pm
Location: Lyss, Switzerland

Re: format timestamp in 'headerFields'

Postby thyon » Tue Feb 23, 2010 9:26 am

This is easily fixed. Just add an entry into your ['fields'] array for 'tstamp'. You can specify the eval option to be date formatted and also the label to be used. Just DO NOT specify the inputType, otherwise it can become editable with a control. That's all you need. TL will take the value and format it using your spec. You can do this with any field you haven't actually allowed for editing, e.g. PID, ID, etc...
User avatar
thyon
Developer
 
Posts: 722
Joined: Wed Jun 10, 2009 10:02 pm
Location: Cape Town, South Africa

Re: format timestamp in 'headerFields'

Postby synergie » Tue Feb 23, 2010 9:58 am

yes we ask the modification for 2.8, it is ok now!

ticket closed
User avatar
synergie
User
 
Posts: 41
Joined: Mon Nov 23, 2009 2:27 pm
Location: Valais, Switzerland

Re: format timestamp in 'headerFields'

Postby thyon » Tue Feb 23, 2010 10:22 am

yes, but my description works for installations pre-2.8 as well.
User avatar
thyon
Developer
 
Posts: 722
Joined: Wed Jun 10, 2009 10:02 pm
Location: Cape Town, South Africa

Re: format timestamp in 'headerFields'

Postby synergie » Tue Feb 23, 2010 10:49 am

yes thanks
User avatar
synergie
User
 
Posts: 41
Joined: Mon Nov 23, 2009 2:27 pm
Location: Valais, Switzerland


Return to Developer's corner

Who is online

Users browsing this forum: No registered users