Template: ezcTemplateCustomFunctionDefinition
[ ]
[ EBNF ] [ Functions ]
[ ]
[ ]
[ ]
[ ]
Class: ezcTemplateCustomFunctionDefinition
|
Contains the definition of a custom function. [
source]
Example of use: create a function to hide a mail address.
- Create a class which implements ezcTemplateCustomFunction and which
will be included in your application (with the autoloading mechanism).
1. class htmlFunctions implements ezcTemplateCustomFunction
2. {
3. public static function getCustomFunctionDefinition( $name )
4. {
5. switch ($name )
6. {
7. case "hide_mail":
8. $def = new ezcTemplateCustomFunctionDefinition();
9. $def->class = __CLASS__;
10. $def->method = "hide_mail";
11. $def->parameters = array( "mailAddress" );
12. return $def;
13. }
14. return false;
15. }
16.
17. public static function hide_mail( $mailAddress )
18. {
19. $old = array( '@', '.' );
20. $new = array( ' at ', ' dot ' );
21. return str_replace( $old, $new, $mailAddress );
22. }
23. }
3. Use the custom function in the template.
1. {hide_mail( "john.doe@example.com" )}
The generated html code for this will be: john dot doe at example dot com
Parents
ezcTemplateCustomExtension
|
--ezcTemplateCustomFunctionDefinition
Member Variables
|
public string |
$class
Holds the (static) class that implements the function to be executed. |
|
public string |
$method
Holds the (static) method that should be run. |
|
public array(string) |
$parameters
= array()
Holds the required and optional named parameters for this custom function. |
|
public mixed |
$sendTemplateObject
= false
|
Last updated: Thu, 01 Nov 2007