ePages 6.15.1 - 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
GetAllInfoTemplateType

Functions

GetAllInfoTemplateType
GetTLEProcessor
INCLUDE
IsEmpty
ProcessPage
dictionaryFiles
templateFileName

GetAllInfoTemplateType

Returns the attributes of all objects of class "TemplateType" as hash.

Syntax
$ahInfo = GetAllInfoTemplateType();
Example
@$ahInfo = @{GetAllInfoTemplateType()};
Input
$CartridgeID (integer)
cartridge id (optional)
Return
$ahInfo (ref.array.hash)
template type info with keys:
  • TemplateTypeID - template type id - integer
  • Name - template type name - string
  • ObjectID - object id - integer
  • FileName - file name - string
  • CartridgeID - cartridge id - integer

GetTLEProcessor

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

Syntax
$TLEProcessor = GetTLEProcessor();
$TLEProcessor = GetTLEProcessor($CacheName,$PackageName);
Example
$TLEProcessor = GetTLEProcessor('SitePageProcessor',__PACKAGE__);
Input
$CacheName (string)
(optional, default: 'PageProcessor')
name of the cache entry
$PackageName (string)
(optional, default: 'DE_EPAGES::TLE::API::BaseProcessor')
package name
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). WithDebugInfo strings can be: "NoDebug", "JsDebug", "CssDebug" or "HtmlDebug".

Syntax
#INCLUDE(#Name, #NoDebug)
Example
#INCLUDE("Header") ... #INCLUDE("Footer")
#INCLUDE("StyleSheet", "NoDebug")
Input
#TemplateName (string)
name of the template
#WithDebugInfo (string)
type of the debug info to include
Return
$result (string)
final template

IsEmpty

Returns true if the value is empty respectively has only debug comments

Syntax
#IsEmpty(#Value)
Example
#IsEmpty(#INCLUDE("Footer"))

ProcessPage

Localizes a template by replacing localization tags, then replaces embedded placeholders (TLE variables). Returns the complete page content. Note: the parameter $LanguageCode specifies the language for localization tags in the template , i.e. static content. The language for dynamic content, such as attributes of type LocalizedString is specified by the global variable $DE_EPAGES::Object::API::Language::LANGUAGEID.

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 );
{
    local $DE_EPAGES::Object::API::Language::LANGUAGEID = GetPKeyLanguageByCode('en');
    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)
$DefaultFormatting (string)
(optional) set formatting - default value is 'html'
Return
$Content (string)
replaced content

dictionaryFiles

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

Syntax
$aFiles = $Handler->dictionaryFiles( $FileName, $LanguageIdentifier );
Example
$aFiles = $Handler->dictionaryFiles( 'Template.tmpl', 'de' );
Input
$FileName (string)
template file name
$LanguageIdentifier (string)
language identifier could be 'en' but also 'en-US'
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