Template: ezcTemplateCustomBlockDefinition
[ ]
[ EBNF ] [ Functions ]
[ ]
[ ]
[ ]
[ ]
Class: ezcTemplateCustomBlockDefinition
|
Contains the definition of a custom block. [
source]
Example of use: create a link custom block.
- Create a class which implements ezcTemplateCustomBlock and which
will be included in your application (with the autoloading mechanism).
1. class htmlBlocks implements ezcTemplateCustomBlock
2. {
3. public static function getCustomBlockDefinition( $name )
4. {
5. switch ( $name )
6. {
7. case "link":
8. $def = new ezcTemplateCustomBlockDefinition();
9. $def->class = __CLASS__;
10. $def->method = 'link';
11. $def->hasCloseTag = false;
12. $def->startExpressionName = 'from';
13. $def->requiredParameters = array( 'title' );
14. $def->optionalParameters = array( 'from', 'to' );
15. return $def;
16. }
17. return false;
18. }
19.
20. public static function link( $parameters )
21. {
22. $title = "";
23. if ( isset( $parameters['title'] ) )
24. {
25. $title = "title=\"{$parameters['title']}\"";
26. }
27. return "<" . "a href=\"{$parameters['to']}\" {$title}>{$parameters['from']}</a>";
28. }
29. }
3. Use the custom block in the template.
1. {link "Google" to "http://www.google.com" title "Google search engine"}
The generated html code for this will be a hyperlink.
Parents
ezcTemplateCustomExtension
|
--ezcTemplateCustomBlockDefinition
Member Variables
|
public string |
$class
Holds the (static) class that implements the function to be executed. |
|
public bool |
$hasCloseTag
Specifies whether the class has an open and close tag or only a open tag. |
|
public mixed |
$isStatic
= false
|
|
public string |
$method
Holds the (static) method that should be run. |
|
public array(string) |
$optionalParameters
= array()
Holds the optional named parameters for this custom block. |
|
public array(string) |
$requiredParameters
= array()
Holds the required named parameters for this custom block. |
|
public string |
$startExpressionName
Holds the first parameter of a custom block without a name. |
Last updated: Thu, 01 Nov 2007