PHP Classes
elePHPant
Icontem

File: testtemplate.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Niels Scheffers  >  Templato  >  testtemplate.php  >  Download  
File: testtemplate.php
Role: Unit test script
Content type: text/plain
Description: Testing script showing the use of loops
Class: Templato
Template class with looping capabilities
Author: By
Last change:
Date: 12 years ago
Size: 874 bytes
 

Contents

Class file image Download
<?php
include("class.template.php");

// TESTING SCRIPT FOR class.template.php
$testarray = array("This", "Is", "A", "Test");
$testarray2 = array("This", "Is", "Another", "Test");

$myTemplate = new Template("example.html");

$myTemplate->getLoop("LOOP NUMBER 1");
$myTemplate->insertHeader();

reset($testarray); // Set cursor to start
foreach ($testarray as $row) {
   
$myTemplate->resetLoopVar();
   
$myTemplate->setLoopVar("MESSAGE 1", $row);
   
$myTemplate->insertLoop();
}

$myTemplate->getLoop("LOOP NUMBER 2");
$myTemplate->resetLoopVar();
$myTemplate->insertHeader();

reset($testarray2); // Set cursor to start
foreach ($testarray2 as $row) {
   
$myTemplate->resetLoopVar();
   
$myTemplate->setLoopVar("MESSAGE 2", $row);
   
$myTemplate->insertLoop();
}

$myTemplate->resetLoopVar;
$myTemplate->insertFooter();

echo
$myTemplate->output;

?>