diff --git a/docs/en/programmers/plugins/plugins-block-functions.xml b/docs/en/programmers/plugins/plugins-block-functions.xml
index 673314ff..4d626370 100644
--- a/docs/en/programmers/plugins/plugins-block-functions.xml
+++ b/docs/en/programmers/plugins/plugins-block-functions.xml
@@ -11,62 +11,64 @@
- Block functions are functions of the form: {func} .. {/func}. In other
- words, they enclose a template block and operate on the contents of
- this block. Block functions take precedence over custom functions of
- the same name, that is, you cannot have both custom function {func} and
- block function {func} .. {/func}.
+ Block functions are functions of the form:
+ {func} .. {/func}. In other words, they enclose a
+ template block and operate on the contents of
+ this block. Block functions take precedence over
+ custom functions of
+ the same name, that is, you cannot have both custom function
+ {func} and block function
+ {func}..{/func}.
-
+
+
+
By default your function implementation is called twice by
- Smarty: once for the opening tag, and once for the closing tag
- (see &$repeat below how to change this).
-
-
- Only the opening tag of the block function may have attributes. All
+ Smarty: once for the opening tag, and once for the closing tag.
+ (See $repeat below on how to change this.)
+
+
+ Only the opening tag of the block function may have
+ attributes. All
attributes passed to template functions from the template are contained
- in the $params as an associative array. You can
- access those values as e.g. $params['start'].
+ in the $params variable as an associative array.
The opening tag attributes are also accessible to your function
when processing the closing tag.
-
-
- The value of $content variable depends on
+
+
+ The value of the $content variable depends on
whether your function is called for the opening or closing tag. In case
- of the opening tag, it will be null, and in case of
+ of the opening tag, it will be &null;, and in case of
the closing tag it will be the contents of the template block.
Note that the template block will have already been processed by
Smarty, so all you will receive is the template output, not the
template source.
-
+
-
- The parameter &$repeat is passed by
+
+ The parameter $repeat is passed by
reference to the function implementation and provides a
possibility for it to control how many times the block is
displayed. By default $repeat is
- true at the first call of the block-function
- (the block opening tag) and false on all
- subsequent calls to the block function (the block's closing tag).
+ &true; at the first call of the block-function (the opening tag)
+ and &false; on all subsequent calls to the block function
+ (the block's closing tag).
Each time the function implementation returns with
- &$repeat being true, the contents between
- {func} .. {/func} are evaluated and the function implementation
- is called again with the new block contents in the parameter
+ $repeat being &true;, the contents between
+ {func}...{/func} are evaluated and the function
+ implementation is called again with the new block contents in the parameter
$content.
-
-
+
+
If you have nested block functions, it's possible to find out what the
parent block function is by accessing
- $smarty->_tag_stack variable. Just do a var_dump()
+ $smarty->_tag_stack variable. Just do a
+ var_dump()
on it and the structure should be apparent.
-
- See also:
- register_block(),
- unregister_block().
-
+
block function
@@ -83,16 +85,26 @@
*/
function smarty_block_translate($params, $content, &$smarty, &$repeat)
{
- if (isset($content)) {
- $lang = $params['lang'];
- // do some intelligent translation thing here with $content
- return $translation;
+ // only output on the closing tag
+ if(!$repeat){
+ if (isset($content)) {
+ $lang = $params['lang'];
+ // do some intelligent translation thing here with $content
+ return $translation;
+ }
}
}
?>
]]>
+
+
+ See also:
+ register_block(),
+ unregister_block().
+
+
Modifiers
- Modifiers are little functions that are applied to a variable in the
- template before it is displayed or used in some other context.
- Modifiers can be chained together.
+ Modifiers are little functions
+ that are applied to a variable in the template before it is displayed or
+ used in some other context. Modifiers can be chained together.
@@ -15,20 +15,16 @@
The first parameter to the modifier plugin is the value on which
- the modifier is supposed to operate. The rest of the parameters can be
- optional, depending on what kind of operation is supposed to be
- performed.
+ the modifier is to operate. The rest of the parameters are optional,
+ depending on what kind of operation is to be performed.
- The modifier has to return the result of its processing.
-
-
- See also
- register_modifier(),
- unregister_modifier().
+ The modifier has to return
+ the result of its processing.
+
- simple modifier plugin
+ A simple modifier plugin
This plugin basically aliases one of the built-in PHP functions. It
does not have any additional parameters.
@@ -55,7 +51,7 @@ function smarty_modifier_capitalize($string)
- more complex modifier plugin
+ More complex modifier plugin
+
+ See also
+ register_modifier(),
+ unregister_modifier().
+