Path

ez components / documentation / api reference / 2009.2.1 / template


eZ Components 2009.2.1

Template: ezcTemplateConfiguration

[ Tutorial ] [ EBNF ] [ Functions ] [ Class tree ] [ Element index ] [ ChangeLog ] [ Credits ]

Class: ezcTemplateConfiguration

Contains the common configuration options for template managers. [source]
Whenever a template source or compiled code is accessed it will use the $templatePath and $compilePath respectively as the base path. The full path is generated by using the value of theses variables and then appending a slash (/) and the subpath, this means it is possible to have the templates in the root of the filesystem by setting an empty string or a string starting with a slash. The next example demonstrates how the templatePath and compilePath can be set:
 1.  // accessing templates in /usr/share and compile them in /var/cache
 2.  $conf->templatePath "/usr/share/eztemplate";
 3.  $conf->compilePath "/var/cache/eztemplate";
Accessing templates from the applications directory is done with a single dot (.), these are also the default values.
 1.  // uses current directory for accessing templates and compiling them
 2.  $conf->templatePath ".";
 3.  $conf->compilePath ".";
The $context property is by default assigned to an ezcTemplateXhtmlContext object.

Properties

ezcTemplateCacheManager read/write  $cacheManager
The object to use for caching of compile templates.
string read/write  $cachedTemplatesPath
Relative path from the compilePath.
bool read/write  $checkModifiedTemplates
Set to true, to recompile outdated compiled templates.
string read/write  $compilePath
Base path where the compiled templates are stored.
string read/write  $compiledTemplatesPath
Relative path from the compilePath.
ezcTemplateOutputContext read/write  $context
Contains the template context.
array(ezcTemplateCustomBlockDefinition) read/write  $customBlock
The currently registered custom blocks.
array(ezcTemplateCustomFunctionDefinition) read/write  $customFunctions
The currently registered custom functions.
bool read/write  $disableCache
Disable caching for development purposes.
bool read/write  $executeTemplate
False to only compile the template without executing it.
ezcTemplateLocator read/write  $locator
Set the locator object to dynamically translate the template file.
string read/write  $sourceCharset
Charset of the literals in the original template file.
string read/write  $targetCharset
Desired charset of literals in the compiled.
string read/write  $templatePath
Base path where the source templates are stored.
bool read/write  $trimWhitespace
Whether the parser should strip whitespace from the templates.

Method Summary

public ezcTemplateConfiguration __construct( [$templatePath = "."], [$compilePath = "."], [$context = null] )
Initialises the configuration with default template, compiled path, and context.
public void addExtension( $customClass )
Adds custom tags or functions to the customBlock or customFunction property and indirectly adds the custom extension to the template language.
public static ezcTemplateConfiguration getInstance( [$name = "default"] )
Returns the unique configuration instance named $name.

Methods

__construct

ezcTemplateConfiguration __construct( [string $templatePath = "."], [string $compilePath = "."], [ezcTemplateOutputContext $context = null] )
Initialises the configuration with default template, compiled path, and context.
All requested templates are search from the defined $templatePath. Use an empty string to fetch templates from the root of the filesystem.
All compiled templates are placed in subfolders under the compiled templates. Use an empty string to compile templates at the root of the filesystem.

Parameters

Name Type Description
$templatePath string Path where the source templates are stored.
$compilePath string Path where the compiled templates should be stored.
$context ezcTemplateOutputContext Context to use. Default is the ezcTemplateXhtmlContext.

addExtension

void addExtension( string $customClass )
Adds custom tags or functions to the customBlock or customFunction property and indirectly adds the custom extension to the template language.
The parameter $customBlockClass expects a class that implements either the interface ezcTemplateCustomBlock, ezcTemplateCustomFunction, or both.
New custom blocks are added to the ezcTemplateConfiguration::customBlocks property while custom functions are added to the ezcTemplateConfiguration::customFunctions property.

Parameters

Name Type Description
$customClass string  

Throws

ClassDescription
ezcBaseValueException if the $customClass parameter is not a string, or when the classname that it represents does not implement either the ezcTemplateCustomBlock or ezcTemplateCustomFunction interface.

getInstance

ezcTemplateConfiguration getInstance( [string $name = "default"] )
Returns the unique configuration instance named $name.
Note: You only need to specify the name if you need multiple configuration objects.

Parameters

Name Type Description
$name string Name of the configuration to use.

Last updated: Tue, 23 Mar 2010