>> YANA 4 PHP Framework >> Docs For Class SmartTemplate

Class SmartTemplate

Description

«decorator» SmartTemplate

This implements a decorator class for the smarty template engine. The use of the "decorator" pattern actually means it "implements an API" on top of the original.

Note that this does not touch or even change the engine itself.

This class provides two things: most obviously it provides some features, that smarty does not have and in addition it does some more type checking and automates the initialization process.

  • access: public

Located in /includes/class_smarttemplate.php

Object
   |
   --SmartTemplate
Method Summary

Direct descendents

Class Description
Mailer create and send mails based on templates

Methods

create an instance
SmartTemplate SmartTemplate (
[string $filename = ""]
)
List of parameters:
Name Type Description
$filename string (optional)
Description:

You may enter a filename of a template you want to use.

compare with another object
string equals (
object $another_object
)
List of parameters:
Name Type Description
$another_object object
Description:

Returns bool(true) if this object and $another_object are equal and bool(false) otherwise.

Two instances are considered equal if and only if they are both objects of the same class and they both refer to the same filesystem resource.

  • access: public

Redefinition of: Object::equals()

fetch a template or template var
mixed get (
[string $key = null]
)
List of parameters:
Name Type Description
$key string (optional)
Description:

There are three ways to call this function:

If you call $smartTemplate->get($varName) it will get the template var $varName and return it.

If you call $smartTemplate->get("*") with the wildcard '*' or an empty string '' it will return an associative array containing all template vars.

If you call $smartTemplate->get() without a parameter it will fetch the current template and return it as a string.

  • access: public
get filename of current template
string getFilename ()
Description:

Returns a string containing the path and filename of the current template relative to the framework's home directory.

  • access: public
assign a variable by value
void insert (
string $varName, mixed $var
)
List of parameters:
Name Type Description
$varName string
$var mixed
Description:

This assigns the $var to the name $varName.

Unlike Smarty's "assign()" this function takes an additional value for $varName:

You may use the wildcard '*' to:

  1. $smartTemplate('*', string $var) assign a string to the global token %INSERT_CONTENT_HERE%
  2. $smartTemplate('*', array $var) merge an associative array with the template vars

  • access: public
assign a variable by reference
void insertByReference (
string $varName,  &$var, mixed $var
)
List of parameters:
Name Type Description
$varName string
$var mixed
&$var
Description:

This assigns the $var to the name $varName.

Unlike Smarty's "assign()" this function takes an additional value for $varName:

You may use the wildcard '*' to:

  1. $smartTemplate('*', string $var) assign a string to the global token %INSERT_CONTENT_HERE%
  2. $smartTemplate('*', array $var) merge an associative array with the template vars

  • access: public
insert a file
boolean insertFile (
string $varName, string $filename
)
List of parameters:
Name Type Description
$varName string
$filename string
Description:

Load a file and assign it's content as a string to the provided template var.

You may use the wildcard '*' to assign the file content to the global token %INSERT_CONTENT_HERE%

  • access: public
set filename of current template
boolean setFilename (
string $filename
)
List of parameters:
Name Type Description
$filename string
Description:

You may set another filename of a template to fetch.

Template files may not have a reserved extension like "htaccess", "php", "config" or the like. Files should be adressed from the root, where "index.php" is stored. If you can't access a file, the file does not exist or is not readable, an error is thrown.

  • access: public
output the template
void write ()
Description:

This function will fetch and print the current template to the screen

  • access: public
inherited from base classes

Inherited From Object

Documentation generated on Wed, 22 Nov 2006 20:19:16 +0100 by phpDocumentor 1.3.1

yana author: Thomas MeyerHomepage: www.all-community.de/pub