ePages 6.11.0 - DE_EPAGES/Presentation/API/Template.pm

Package DE_EPAGES::Presentation::API::Template

This module provides page type based template processing, including language dependend keywords.

Base
DE_EPAGES::Dictionary::API::Template
Example
use DE_EPAGES::Presentation::API::Template qw (ProcessPage);
use DE_EPAGES::Presentation::API::PageType qw (LoadPageTypeByAlias);
use DE_EPAGES::Object::API::Factory qw (LoadObjectByPath);

my $Object = LoadObjectByPath('/Shops/DemoShop');
my $PageType = LoadPageTypeByAlias('Details');
my $myContent = ProcessPage($Object, $PageType, 'en', {});
@EXPORT_OK
ProcessPage
GetTLEProcessor

Functions

GetTLEProcessor
INCLUDE
ProcessPage
dictionaryFiles
templateFileName

GetTLEProcessor

Returns an instance of a TLEProcessor. If possible the object will be retrieved from cache otherwise instantiated.

Syntax
$TLEProcessor = GetTLEProcessor();
$TLEProcessor = GetTLEProcessor($CacheName);
Example
$TLEProcessor = GetTLEProcessor('SitePageProcessor');
Input
$CacheName (string)
optional : the name of the Cache entry
Return
$TLEProcessor (object)
an instance of TLEProcessor

INCLUDE

Returns processed content of the include template. If the debugging mode for this function is enabled, an html comment wraps result (includes file name and processing time).

Syntax
#INCLUDE(#Name, #NoDebug)
Example
#INCLUDE("Header") ... #INCLUDE("Footer")
#INCLUDE("StyleSheet", "NoDebug")
Input
#Name (string)
name of an include template
#NoDebug (string)
'NoDebug' (optional)

ProcessPage

Localizes a template by replacing localization tags, then replaces embedded placeholders (TLE variables). Returns the complete page content.

Syntax
$Content = ProcessPage($Object, $ObjectPageType, $LanguageCode, $hVars, $TLEProcessor, $IncludeHandler, $TemplateName);
Example
my $PageType = LoadPageTypeByAlias( 'SF-Category' );
my $ObjectPageType = DE_EPAGES::Presentation::API::Object::ObjectPageType->load( $PageType, $Category );
print ProcessPage( $Category, $ObjectPageType, 'en', $Category->tleHash );
Input
$Object (object)
object
$ObjectPageType (object)
ObjectPageType object
$LanguageCode (string)
language code
$hVars (ref.(hash.array.)*string)
template vars (vars and loops)
$TLEProcessor (object)
(optional) template processor
$IncludeHandler (object)
(optional) include handler
$TemplateName (string)
starting template (default: Page)
Return
$Content (string)
replaced content

dictionaryFiles

Returns a list of dictionary files for a language-neutral template file.

Syntax
$aFiles = $Handler->dictionaryFiles( $FileName, $LanguageCode );
Example
$aFiles = $Handler->dictionaryFiles( 'Template.tmpl', 'de' );
Input
$FileName (string)
template file name
$LanguageCode (string)
language code
Return
$aFiles (array ref)
list of dictionary file names

templateFileName

Returns the path to a template file. If the file does not exist in the store directory ($ENV{EPAGES_STORES}/$StoreName/Templates/$Company/$Cartridge/$FileName), then the default template is taken from the cartridge directory ($ENV{EPAGES_CARTRIDGES}/$Company/$Cartridge/Templates/$FileName).

Syntax
$FileName = $Handler->templateFileName( $hTemplate );
Example
$hTemplate = $PageType->template( 'Page', $Object );
$FileName = $Handler->templateFileName( $hTemplate );
Input
$hTemplate (ref.hash.string)
template info hash, see GetInfoTemplate
Return
$FileName (string)
template file name