From e521084a102f3ee5a862fa34f99b665ca1e54b6e Mon Sep 17 00:00:00 2001 From: pete_morgan Date: Wed, 27 Sep 2006 01:47:51 +0000 Subject: [PATCH] Tidy up of formatting --- .../advanced-features-objects.xml | 60 +++++++----- .../advanced-features-outputfilters.xml | 37 ++++---- .../advanced-features-postfilters.xml | 22 +++-- .../advanced-features-prefilters.xml | 21 +++-- .../section-template-cache-handler-func.xml | 94 ++++++++++++------- .../advanced-features/template-resources.xml | 80 ++++++++-------- 6 files changed, 183 insertions(+), 131 deletions(-) diff --git a/docs/en/programmers/advanced-features/advanced-features-objects.xml b/docs/en/programmers/advanced-features/advanced-features-objects.xml index 421ba1a6..59b08848 100644 --- a/docs/en/programmers/advanced-features/advanced-features-objects.xml +++ b/docs/en/programmers/advanced-features/advanced-features-objects.xml @@ -3,17 +3,26 @@ Objects - Smarty allows access to PHP - objects through the templates. - There are - two ways to access them. One way is to - register objects to the template, - then use access them via syntax similar to - custom functions. - The other way - is to assign() objects - to the templates and access them much like any other - assigned variable. The first method has a much nicer template syntax. It + Smarty allows access to PHP + objects through the templates. + There are two ways to access them. + + + + + One way is to register objects to + the template, then use access them via syntax similar to + custom functions. + + + The other way is to assign() + objects to the templates and access them much like any other + assigned variable. + + + + + The first method has a much nicer template syntax. It is also more secure, as a registered object can be restricted to certain methods or properties. However, a registered object cannot be looped over @@ -22,9 +31,9 @@ keep template syntax to a minimum. - If $security is enabled, - no private methods or functions can be accessed - (begininning with "_"). If a method and property of the same name exist, + If $security + is enabled, no private methods or functions can be accessed + (begininning with '_'). If a method and property of the same name exist, the method will be used. @@ -38,19 +47,20 @@ An associative array is passed as the first parameter, and the smarty object as the second. If you want the parameters passed one at a time for each argument like traditional - object parameter passing, set the fourth registration parameter to false. + object parameter passing, set the fourth registration parameter to &false;. The optional fifth parameter has only effect with - format being true + format being &true; and contains a list of methods that should be treated as blocks. That means these methods have a closing tag in the template ({foobar->meth2}...{/foobar->meth2}) and the parameters to the methods have the same synopsis as the parameters for - block-function-plugins: - They get 4 parameters + + block-function-plugins: + They get the four parameters $params, $content, &$smarty and @@ -58,7 +68,7 @@ block-function-plugins. - using a registered or assigned object + Using a registered or assigned object register_object('foobar',$myobj); + // if we want to restrict access to certain methods or properties, list them $smarty->register_object('foobar',$myobj,array('meth1','meth2','prop1')); + // if you want to use the traditional object parameter format, pass a boolean of false $smarty->register_object('foobar',$myobj,null,false); -// We can also assign objects. Assign by ref when possible. +// We can also assign objects. assign_by_ref when possible. $smarty->assign_by_ref('myobj', $myobj); $smarty->display('index.tpl'); @@ -86,7 +99,7 @@ $smarty->display('index.tpl'); ]]> - And here's how to access your objects in index.tpl: + And here's how to access your objects in index.tpl: See also register_object() and assign() + linkend="api.register.object">register_object() + and + assign().