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

Class SmartTemplate

Description

SmartTemplate

  • access: public

Located in /includes/class_smarttemplate.php

SerializeableObject
   |
   --SmartTemplate

Direct descendents

Class Description
Mailer create and send mails based on templates

Method Summary

SmartTemplate SmartTemplate ([string $filename = ""])
mixed get ([string $key = null])
string getFilename ()
void insert (string $varName, mixed $var)
void insertByReference (string $varName, mixed &$var)
boolean insertFile (string $varName, string $filename)
boolean setFilename (string $filename)
void write ()

Methods

Constructor SmartTemplate
SmartTemplate SmartTemplate ([string $filename = ""])

create an instance

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

Name Type Description
$filename string (optional)
get
mixed get ([string $key = null])

fetch a template or template var

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
Name Type Description
$key string (optional)
getFilename
string getFilename ()

get filename of current template

  • access: public
insert
void insert (string $varName, mixed $var)

assign a variable by value

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
Name Type Description
$varName string
$var mixed
insertByReference
void insertByReference (string $varName, mixed &$var)

assign a variable by reference

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
Name Type Description
$varName string
$var mixed
insertFile
boolean insertFile (string $varName, string $filename)

insert a file

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
Name Type Description
$varName string
$filename string
setFilename
boolean setFilename (string $filename)

set filename of current template

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
Name Type Description
$filename string
write
void write ()

output the template

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

  • access: public

Inherited Methods

Inherited From SerializeableObject

SerializeableObject::serialize()
SerializeableObject::toString()

Documentation generated on Sat, 16 Sep 2006 17:06:04 +0200 by phpDocumentor 1.3.0RC4

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