PHP Classes
elePHPant
Icontem

File: example_settings.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Kalle Sommer Nielsen  >  Template Processor  >  example_settings.php  >  Download  
File: example_settings.php
Role: Example script
Content type: text/plain
Description: Example file - Using settings
Class: Template Processor
Template processing engine
Author: By
Last change: Updated to match the latest class version
Date: 8 years ago
Size: 1,471 bytes
 

Contents

Class file image Download
<?php
   
/**
     * Load class
     */
   
require_once("./template.class.php");

   
/**
     * Make object instance
     */
   
$temp = new Template();

   
/**
     * This is a very odd example, but its show how the
     * get_configuration() function works
     * (return as object, without tempvars included)
     */
   
$cfg = $temp->get_configuration(true);

   
/**
     * Using set_option() allows us to change
     * options that has already been set by default or by the constructor
     *
     * Note, the set_option() does not support Resource/Object/Array datatypes!
     *
     * In this exampe we want to turn on the "allowphp" option, which
     * makes it possible to compile php code in all templates.
     *
     * Since we wanted to see how the get configuration worked, then
     * we make an if to test before setting it
     */
   
if(!$cfg->allowphp)
    {
       
$temp->set_option('allowphp', true);
    }

   
/**
     * We could also have passed it as the constructors
     * first parameter when making an instance of the class
     * like this:
     *
     * $temp = new Template(Array('allowphp' => true));
     *
     * Or here when we're adding multiple configuration options
     * in one call:
     *
     * $temp = new Template(Array('allowphp' => true, 'vartype' => 'php'));
     *
     */

    /**
     * Add a piece of code to the cache and compile it to
     * test that "allowphp" is working correctly.
     */
   
$temp->addcache('<?php echo("Hello World"); ?>');

   
/**
     * Compile
     */
   
$temp->compile();
?>