Forums / Cotonti / Development / Siena Beta Testing

Bugfixing and evaluation cycle started

GHengeveld
#28347 2011-02-15 22:09
# pieter : How can I change the output of {LIST_ROW_DATE} ?
Now it is date AND time. And I don't want the time to be displayed in page.list.tpl
Use this:
{LIST_ROW_DATE_STAMP|cot_date('date_full', $this)}
See lang/en/main.en.lang.php line 362 for a list of possible values instead of 'date_full'. You can also specify the date format directly by replacing 'date_full' with something like 'd-m-Y'. Downside is that the format will be fixed in that case, while 'date_full' can be different between languages.

Every tag in CoTemplate (Cotonti's implementation of XTemplate) can have a 'callback function' specified. You do this by putting a 'pipe' sign | at the end of the tag name, followed by a PHP function. This can be both PHP native functions, or user-specified functions (from plugins for example). The function can take one dynamic variable, $this, which takes the value of the tag preceding the function. Since {LIST_ROW_DATE_STAMP} returns a Unix timestamp (integer), the value of $this will be this timestamp. cot_date() takes 2 parameters: a datetime format (like the date() function) and a timestamp. CoTemplate will replace the tag inside the template with the value returned by the callback function instead of the value of the tag itself. It's not possible to put template tags as parameters for the callback function, so callbacks are limited to just one dynamic parameter ($this).
This post was edited by Koradhil (2011-02-15 22:20, 13 years ago)