Zeta Components Manual :: Docs For Class ezcTemplateCustomBlockDefinition
Template::ezcTemplateCustomBlockDefinition
Class ezcTemplateCustomBlockDefinition
Contains the definition of a custom block.
Example of use: create a link custom block.
- Create a class which implements ezcTemplateCustomBlock and which
- class htmlBlocks implements ezcTemplateCustomBlock
- {
- public static function getCustomBlockDefinition( $name )
- {
- switch ( $name )
- {
- case "link":
- $def->class = __CLASS__;
- $def->method = 'link';
- $def->hasCloseTag = false;
- $def->startExpressionName = 'from';
- $def->requiredParameters = array( 'title' );
- $def->optionalParameters = array( 'from', 'to' );
- return $def;
- }
- return false;
- }
- public static function link( $parameters )
- {
- $title = "";
- if ( isset( $parameters['title'] ) )
- {
- $title = "title=\"{$parameters['title']}\"";
- }
- return "<" . "a href=\"{$parameters['to']}\" {$title}>{$parameters['from']}</a>";
- }
- }
2. Assign the class to the Template configuration in your application.
- $config->addExtension( "htmlBlocks" );
3. Use the custom block in the template.
Source for this file: /Template/src/structs/custom_block_definition.php
ezcTemplateCustomExtension | --ezcTemplateCustomBlockDefinition
Version: | //autogen// |
Member Variables
public string |
$class
Holds the (static) class that implements the function to be executed. |
public bool |
$excessParameters
= false
When excessParameters is set to true, the custom block accepts any amount of parameters over the required parameters. |
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 bool |
$sendTemplateObject
= false
Whether or not the Template object is available in the custom block. Be aware that if you change this, your custom block's signature changes as the first argument will then be the template object. |
public string |
$startExpressionName
Holds the first parameter of a custom block without a name. If the custom block should have a start expression then this variable specifies a name for it. The name should reappear in either the optionalParameters or the requiredParameters. |
Documentation generated by phpDocumentor 1.4.3