mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 02:44:27 +02:00
various things
This commit is contained in:
@@ -3,8 +3,8 @@
|
|||||||
<chapter id="bugs">
|
<chapter id="bugs">
|
||||||
<title>BUGS</title>
|
<title>BUGS</title>
|
||||||
<para>
|
<para>
|
||||||
Check the BUGS file that comes with the latest distribution of Smarty, or
|
Check the <filename>BUGS</filename> file that comes with
|
||||||
check the website.
|
the latest distribution of Smarty, or check the website.
|
||||||
</para>
|
</para>
|
||||||
</chapter>
|
</chapter>
|
||||||
<!-- Keep this comment at the end of the file
|
<!-- Keep this comment at the end of the file
|
||||||
|
@@ -120,10 +120,12 @@ footer.tpl
|
|||||||
control over date formatting, and also makes it easy to compare dates if
|
control over date formatting, and also makes it easy to compare dates if
|
||||||
necessary.
|
necessary.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<note>
|
||||||
NOTE: As of Smarty 1.4.0, you can pass dates to Smarty as unix
|
<para>
|
||||||
timestamps, mysql timestamps, or any date parsable by strtotime().
|
As of Smarty 1.4.0, you can pass dates to Smarty as unix
|
||||||
</para>
|
timestamps, mysql timestamps, or any date parsable by strtotime().
|
||||||
|
</para>
|
||||||
|
</note>
|
||||||
<example>
|
<example>
|
||||||
<title>using date_format</title>
|
<title>using date_format</title>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
@@ -160,18 +162,21 @@ OUTPUT:
|
|||||||
// this assumes your form elements are named
|
// this assumes your form elements are named
|
||||||
// startDate_Day, startDate_Month, startDate_Year
|
// startDate_Day, startDate_Month, startDate_Year
|
||||||
|
|
||||||
$startDate = makeTimeStamp($startDate_Year,$startDate_Month,$startDate_Day);
|
$startDate = makeTimeStamp($startDate_Year, $startDate_Month, $startDate_Day);
|
||||||
|
|
||||||
function makeTimeStamp($year="",$month="",$day="")
|
function makeTimeStamp($year="", $month="", $day="")
|
||||||
{
|
{
|
||||||
if(empty($year))
|
if(empty($year)) {
|
||||||
$year = strftime("%Y");
|
$year = strftime("%Y");
|
||||||
if(empty($month))
|
}
|
||||||
|
if(empty($month)) {
|
||||||
$month = strftime("%m");
|
$month = strftime("%m");
|
||||||
if(empty($day))
|
}
|
||||||
|
if(empty($day)) {
|
||||||
$day = strftime("%d");
|
$day = strftime("%d");
|
||||||
|
}
|
||||||
|
|
||||||
return mktime(0,0,0,$month,$day,$year);
|
return mktime(0, 0, 0, $month, $day, $year);
|
||||||
}
|
}
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
@@ -195,10 +200,12 @@ function makeTimeStamp($year="",$month="",$day="")
|
|||||||
|
|
||||||
// be sure apache is configure for the .wml extensions!
|
// be sure apache is configure for the .wml extensions!
|
||||||
// put this function somewhere in your application, or in Smarty.addons.php
|
// put this function somewhere in your application, or in Smarty.addons.php
|
||||||
function insert_header($params) {
|
function insert_header($params)
|
||||||
|
{
|
||||||
// this function expects $content argument
|
// this function expects $content argument
|
||||||
if(empty($params['content']))
|
if (empty($params['content'])) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
header($params['content']);
|
header($params['content']);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -265,18 +272,20 @@ Pretty easy isn't it?
|
|||||||
// drop file "function.load_ticker.php" in plugin directory
|
// drop file "function.load_ticker.php" in plugin directory
|
||||||
|
|
||||||
// setup our function for fetching stock data
|
// setup our function for fetching stock data
|
||||||
function fetch_ticker($symbol) {
|
function fetch_ticker($symbol)
|
||||||
|
{
|
||||||
// put logic here that fetches $ticker_info
|
// put logic here that fetches $ticker_info
|
||||||
// from some ticker resource
|
// from some ticker resource
|
||||||
return $ticker_info;
|
return $ticker_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
function smarty_function_load_ticker($params, &$smarty) {
|
function smarty_function_load_ticker($params, &$smarty)
|
||||||
|
{
|
||||||
// call the function
|
// call the function
|
||||||
$ticker_info = fetch_ticker($params['symbol']);
|
$ticker_info = fetch_ticker($params['symbol']);
|
||||||
|
|
||||||
// assign template variable
|
// assign template variable
|
||||||
$smarty->assign($params['assign'],$ticker_info);
|
$smarty->assign($params['assign'], $ticker_info);
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
]]>
|
]]>
|
||||||
|
Reference in New Issue
Block a user