PHP Classes

File: quicktemplate_ex.php

Recommend this page to a friend!
  Classes of Jesus M. Castagnetto   Generalized CachedTemplate class   quicktemplate_ex.php   Download  
File: quicktemplate_ex.php
Role: ???
Content type: text/plain
Description: Example using the QuickTemplate class
Class: Generalized CachedTemplate class
General Template Caching class
Author: By
Last change:
Date: 24 years ago
Size: 2,071 bytes
 

Contents

Class file image Download
<html> <body> <?php /* * $Id: quicktemplate_ex.php,v 1.3 2000/07/16 19:33:46 jesus Exp $ */ /* * Example modified from the QuickTemplate manual -- JMC */ require "./class.QuickTemplate.php3"; require "./class.QuickTemplateAdaptor.php"; require "./class.CachedTemplate.php"; $qtpl = new CachedTemplate(); $qtpl->init("first_example.tpl"); // for benchmarking $start = $qtpl->utime(); // Check if we can send the cached file if ($qtpl->valid_cache_file()) { echo "<B>FROM CACHE</B>\n<BR>"; $qtpl->read_from_cache(); $end = $qtpl->utime(); $runtime = ($end - $start) * 1000; echo "Completed in $runtime miliseconds<BR>\n"; exit; } $MARKS["John"] = 10; $MARKS["Michael"] = 9; $MARKS["Bob"] = 7; $MARKS["Robert"] = 8; $MARKS["Jane"] = 7; $MARKS["Alice"] = 9; $MARKS["David"] = 10; $MARKS["James"] = 8; $MARKS["Toni"] = 7; $MARKS["Bebe"] = 9; $CLASSES["101A"] = array("John", "Robert", "Jane"); $CLASSES["101B"] = array("Bob", "Alice", "Bebe", "Toni"); $CLASSES["100C"] = array("Michael", "David", "James"); $CLASSES["100D"] = array(); $qtpl->SetNullString(" <b>-</b>"); $qtpl->SetAutoincrement("main.table.row", 1); $qtpl->Assign("MYNAME", "Bebe"); while (list($Class, $Members) = each($CLASSES)) { $qtpl->Assign("CLASSROOM",$Class); if (gettype($Members) == "array") while (list($k, $member) = each($Members)) { $MEMBERDATA = array(NAME => $member, MARK => $MARKS[$member]); $qtpl->Assign("DATA", $MEMBERDATA); $qtpl->parse("main.table.row"); } if (!$qtpl->Parsed("main.table.row")) $qtpl->parse("main.table.error"); $qtpl->parse("main.table"); } $qtpl->parse("main"); // get parsed document $data = $qtpl->getParsedDoc("main"); // output the page echo $data; // for benchmarking $end = $qtpl->utime(); $runtime = ($end - $start) * 1000; echo "Completed in $runtime miliseconds<BR>\n"; // we write the file at the end so this // operation will not be counted in the benchmark $qtpl->write_to_cache($data); ?> </body> </html>