mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 02:44:27 +02:00
fixed examples for register_function() and register_block()
This commit is contained in:
@@ -1151,10 +1151,10 @@ $smarty->load_filter('output', 'compress'); // load output filter named 'compres
|
|||||||
$smarty->register_block("translate", "do_translation");
|
$smarty->register_block("translate", "do_translation");
|
||||||
|
|
||||||
function do_translation ($params, $content, &$smarty, &$repeat) {
|
function do_translation ($params, $content, &$smarty, &$repeat) {
|
||||||
if ($content) {
|
if (isset($content)) {
|
||||||
$lang = $params['lang'];
|
$lang = $params['lang'];
|
||||||
// do some translation with $content
|
// do some translation with $content
|
||||||
echo $translation;
|
return $translation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1237,7 +1237,7 @@ function print_current_date ($params) {
|
|||||||
extract($params);
|
extract($params);
|
||||||
if(empty($format))
|
if(empty($format))
|
||||||
$format="%b %e, %Y";
|
$format="%b %e, %Y";
|
||||||
echo strftime($format,time());
|
return strftime($format,time());
|
||||||
}
|
}
|
||||||
|
|
||||||
// now you can use this in Smarty to print the current date: {date_now}
|
// now you can use this in Smarty to print the current date: {date_now}
|
||||||
@@ -2893,10 +2893,10 @@ function smarty_modifier_truncate($string, $length = 80, $etc = '...',
|
|||||||
*/
|
*/
|
||||||
function smarty_block_translate($params, $content, &$smarty)
|
function smarty_block_translate($params, $content, &$smarty)
|
||||||
{
|
{
|
||||||
if ($content) {
|
if (isset($content)) {
|
||||||
$lang = $params['lang'];
|
$lang = $params['lang'];
|
||||||
// do some intelligent translation thing here with $content
|
// do some intelligent translation thing here with $content
|
||||||
echo $translation;
|
return $translation;
|
||||||
}
|
}
|
||||||
}</programlisting>
|
}</programlisting>
|
||||||
</example>
|
</example>
|
||||||
|
Reference in New Issue
Block a user