diff --git a/docs.sgml b/docs.sgml
index dcbc3710..536767b2 100644
--- a/docs.sgml
+++ b/docs.sgml
@@ -390,9 +390,9 @@ require_once(SMARTY_DIR."Smarty.class.php");
TECHNICAL NOTE: Server variables can be accessed through the
- $smarty variable, such as {$smarty.env.SCRIPT_NAME}. See the
- section on the $smarty variable.
+ $smarty variable, such as {$smarty.server.SCRIPT_NAME}. See the
+ section on the
+ $smarty variable.
@@ -5145,43 +5145,6 @@ OUTPUT:
-
- Creating your own Custom Functions
-
- Creating your own functions is a fairly straight forward process.
- The best way is to look at the ones that come with Smarty as
- examples. The function names begin with smarty_func_ and they are
- located in the Smarty.addons.php file.
-
-
- add your function to the Smarty.addons.php file.
- It is recommended that you prepend your function name
- with smarty_func_
- map a template function name to your PHP function.
- This is done at the top of the Smarty.class.php file
- in the $custom_funcs array.
- Thats it! you can now call that function
- from within Smarty.
-
-
- All attributes passed to custom functions are passed into the
- first argument as an associative array. One way to get to those
- values is to call extract(func_get_arg(0)); at the top of your
- function. Anything that the function returns gets displayed
- in place of the tag in the template.
-
-
- Since version 1.4.0, custom functions are also passed Smarty object
- as the second parameter. If the custom function declares the second
- parameter passed by reference, it can then use Smarty object's
- variable assignment and clearing functions to manipulate template
- variables dynamically.
-
-
- You can also add custom functions programatically with the register_function API.
-
- Variable Modifiers
@@ -6113,29 +6076,6 @@ s m o k e r s a r e p. . .
-
- Creating your own Variable Modifiers
-
- Creating your own modifiers is a fairly straight forward process.
- The best way is to look at the ones that come with Smarty as
- examples. The function names begin with smarty_mod_ and they are
- located in the Smarty.addons.php file.
-
-
- add your modifier to the Smarty.addons.php file.
- It is recommended that you prepend your function name
- with smarty_mod_
- map a template modifier name to your PHP function.
- This is done at the top of the Smarty.class.php file
- in the $custom_mods array.
- Thats it! you can now use that modifier
- from within Smarty.
-
-
- You can also add modifiers programatically with the register_modifier API.
-
-
@@ -6174,6 +6114,11 @@ s m o k e r s a r e p. . .
because these filters are never explicitly mentioned in the template
language.
+
+ There is only one plugins directory (for performance reasons). To
+ install a plugin, simply place it in the directory and Smarty will use
+ it automatically.
+ Naming Conventions
@@ -6228,7 +6173,7 @@ s m o k e r s a r e p. . .
- Note that even though pre/postfilters still have to be correctly
+ Note that pre/postfilters still have to be correctly
named even though the names are not really used for anything.
@@ -6322,7 +6267,7 @@ function smarty_function_eightball($params, &$smarty)
which can be used in the template as:
-Question:
+Question: Will we ever have time travel?
Answer: {eightball}.
@@ -6365,15 +6310,84 @@ function smarty_function_assign($params, &$smarty)
modifiers
+
+
+ mixed plugin_name
+ mixed $value
+ [mixed $param1, ...]
+
+
+ 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 has to return the result of its processing.
+
+
+
+ simple modifier plugin
+
+<?php
+/*
+ * Smarty plugin
+ * -------------------------------------------------------------
+ * File: modifier.capitalize.php
+ * Type: modifier
+ * Name: capitalize
+ * Purpose: capitalize words in the string
+ * -------------------------------------------------------------
+ */
+function smarty_modifier_capitalize($string)
+{
+ return ucwords($string);
+}
+?>
+
+
+
+ This plugin basically aliases one of the built-in PHP functions. It
+ does not have any additional parameters.
- modifier plugin
+ more complex modifier plugin
+<?php
+/*
+ * Smarty plugin
+ * -------------------------------------------------------------
+ * File: modifier.truncate.php
+ * Type: modifier
+ * Name: truncate
+ * Purpose: Truncate a string to a certain length if necessary,
+ * optionally splitting in the middle of a word, and
+ * appending the $etc string.
+ * -------------------------------------------------------------
+ */
+function smarty_modifier_truncate($string, $length = 80, $etc = '...',
+ $break_words = false)
+{
+ if ($length == 0)
+ return '';
+ if (strlen($string) > $length) {
+ $length -= strlen($etc);
+ $fragment = substr($string, 0, $length+1);
+ if ($break_words)
+ $fragment = substr($fragment, 0, -1);
+ else
+ $fragment = preg_replace('/\s+(\S+)?$/', '', $fragment);
+ return $fragment.$etc;
+ } else
+ return $string;
+}
+?>
+
compiler functions