These are functions that may be used in many contexts.
Capture lets you extract parts of code into instance variables which can be used in other points of the template or even layout file.
<?php $capture_helper->begin (); ?> [some html...] <?php $script = $capture_helper->end (); ?>
$capture_helper→content_for(“name”); is a wrapper for Capture which will store the fragment in an instance variable similar to $content_for_layout.
Example:
layout.tpl:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>layout with js</title> <script type="text/javascript"> {content_for_script} </script> </head> <body> {content_for_layout} </body> </html>
view.tpl:
This page shows an alert box!
<?php $capture_helper->begin ('script'); ?> alert('hello world'); <?php $capture_helper->end (); ?> Normal view text
Syntax:
distance_of_time_in_words( $from_time, [ $to_time = 0], [ $include_seconds = false])
Description:
Reports the approximate difference in time between $from_time and $to_time in an ISO string translated to the current language:
| Time Difference | Message |
|---|---|
| < 20 seconds | less than x seconds* |
| < 40 seconds | less than half a minute* |
| < 60 seconds | less than a minute |
| 1 minute | 1 minute |
| < = 45 minutes | x minutes |
| < = 90 minutes | about 1 hour |
| < = 1440 minutes | about x hours |
| < = 2880 minutes | 1 day |
| > 2880 minutes | x days |
* reported only if $include_seconds = true; otherwise “less than a minute”.
Syntax:
distance_of_time_in_words_to_now ( $from_time, [ $include_seconds = false])
Description:
Reports the approximate difference in time between $from_time until now (the current time) in an ISO string translated to the current language:
| Time Difference | Message |
|---|---|
| < 20 seconds | less than x seconds* |
| < 40 seconds | less than half a minute* |
| < 60 seconds | less than a minute |
| 1 minute | 1 minute |
| < = 45 minutes | x minutes |
| < = 90 minutes | about 1 hour |
| < = 1440 minutes | about x hours |
| < = 2880 minutes | 1 day |
| > 2880 minutes | x days |
* reported only if $include_seconds = true; otherwise “less than a minute”.
Syntax:
locale_date( [ $iso_date ])
Description:
Converts an ISO date (format: yyyy-mm-dd) to the current date locale format. If $iso_date is omitted, the current date is assumed.
Syntax:
locale_date_time( [ $iso_date_time = null])
Description:
Converts an ISO date/time (format: yyyy-mm-dd hh:mm:ss) to the current locale format. If $iso_date_time is omitted, the current date/time is assumed.
Syntax:
time_ago_in_words ( $from_time, [ $include_seconds ])
Description:
Reports the approximate distance in time between $from_time and timestamp() (the current time) in an ISO string translated to the current language:
| Time Difference | Message |
|---|---|
| < 20 seconds | less than x seconds* |
| < 40 seconds | less than half a minute* |
| < 60 seconds | less than a minute |
| 1 minute | 1 minute |
| ⇐ 45 minutes | x minutes |
| ⇐ 90 minutes | about 1 hour |
| ⇐ 1440 minutes | about x hours |
| ⇐ 2880 minutes | 1 day |
| > 2880 minutes | x days |
* reported only if $include_seconds = true; otherwise “less than a minute”.
Syntax:
_add_one( $number)
Description:
Returns $number++ or $number+1
Syntax:
_leading_zero_on_single_digits( $number)
Description:
This returns
$number > 9 ? $number : "0$number";