Skip to content

classes_base_template.class

Daniel Spors edited this page Nov 11, 2020 · 3 revisions

Classes in file base/template.class.php

class Template

Building blocks of web pages. Each template consist of a logic part and a layout part. The logic part is optional and can be handled by this (base) class (see Template::Make).

Namespace: ScavixWDF\Base

Extends: Renderable

Subclasses: GoogleAnalytics, HtmlPage, SocialBookmarks

add2var

Adds a value to an already defined var. If $name is not already an array it will be converted to one.

$tpl->set('a','one');	
$tpl->add2var('a','two');	
// $a is now array('one','two')	
$tpl->set('a','three');	
// $a is now 'three'	
$tpl->add2var('b','four');	
// $b is now array('four')	

Definition: public function add2var($name, $value)

Returns: Template $this

Parameters:

  • string $name Variable name

  • mixed $value Value to add

get

Gets a variables value.

Definition: public function get($name)

Returns: mixed Value of var

Parameters:

  • string $name Var name

get_vars

Gets all variables.

Definition: public function get_vars()

Returns: array All variables

Make

Creates a template with layout only. Sometimes you just want to separate parts of your layout without giving them some special logic. You may just store them as *.tpl.php files and create a template from them like this:

// assuming template file is 'templates/my.tpl.php'	
$tpl = Template::Make('my');	
$tpl->set('myvar','I am just layout');	

Definition: public static function Make($template_basename=false)

Returns: Template The created template

Parameters:

  • string $template_basename Name of the template

PreRender

INTERNAL Will be executed on HOOK_PRE_RENDER. Prepares the template for output.

set

Set a variable for use in template file.

Definition: public function set($name, $value)

Returns: Template $this

Parameters:

  • string $name Var can be use in template under this name

  • mixed $value The value

set_vars

Sets all template variables.

Definition: public function set_vars($vars, $clear=false)

Returns: Template $this

Parameters:

  • array $vars Key=>Value pairs of variables

  • bool $clear Overwrite the whole vars (defaults to false)

WdfRender

OVERRIDE Renderable::WdfRender

WdfRenderAsRoot

OVERRIDE Renderable::WdfRenderAsRoot

__construct

The one and only constructor for all subclasses. These must not implement a constructor but the __initialize method.

Definition: public function __construct()

Returns: NOT DOCUMENTED

__get

INTERNAL Magic method __get. See Member overloading

__initialize

Override this method instead of writing a constructor.

Definition: public function __initialize($file)

Returns: NOT DOCUMENTED

Parameters:

  • string $file Template file for this class. Usually '' (empty string)
Clone this wiki locally