PHP Classes
Icontem

File: phplibtemplate_example.php


  Search   All class groups All class groups   Latest entries Latest entries   Top 10 charts Top 10 charts   Newsletter Newsletter   Blog Blog   Forums Forums   Help FAQ Help FAQ  
  Login   Register  
Recommend this page to a friend! ReTweet ReTweet Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Jesus M. Castagnetto  >  Generalized CachedTemplate class  >  phplibtemplate_example.php  
File: phplibtemplate_example.php
Role: ???
Content type: text/plain
Description: Example using the PHPLIB'x Template class
Class: Generalized CachedTemplate class
General Template Caching class
 

Contents

Class file image Download
<?php

/* $Id: phplibtemplate_example.php,v 1.3 2000/07/16 20:04:34 jesus Exp $ */

include("./phplib_template.inc");
include("./class.PHPLIBTemplateAdaptor.php");
include("./class.CachedTemplate.php");

// create Template instance called $ptpl  
$ptpl = new CachedTemplate();
$start = $ptpl->utime();
$ptpl->init(".", "keep");

// define variables named page and box, referencing files
$ptpl->set_file(array(
	"page" => "ptpl_page.ihtml",
	"box"  => "ptpl_box.ihtml"));

// Check if we can send the cached file
if ($ptpl->valid_cache_file()) {
    echo "<B>FROM CACHE</B>\n<BR>";
    $ptpl->read_from_cache();
    $end = $ptpl->utime();
    $runtime = ($end - $start) * 1000;
    echo "<br>Completed in $runtime miliseconds<BR>\n";
    exit;
}

// Otherwise process the page
// extract the block named "row" from "box", creating a
// reference to {rows} in "box".
$ptpl->set_block("box", "row", "rows");

// define the variables TITLE and PAGETITLE
$ptpl->set_var(array(
	"TITLE"     => "PHPLIB Template class example",
	"PAGETITLE" => "Example page",
	"CONTENT_TITLE" => "Content of example",
	"CONTENT_ALIGN" => "center"));

// define NUM and BIGNUM, then append "row" to "rows"...
for ($i=1; $i<=3; $i++) {
 $n  = $i;
 $nn = rand($i*5,$i*15);
 $ptpl->set_var(array("NUM" => $n, "BIGNUM" => $nn));
 $ptpl->parse("rows", "row", true);
}

// build out from box, then build out from page...
$ptpl->parse("OUT", array("box", "page"));

// finish out and print it.
$data = $ptpl->getParsedDoc("OUT");
echo $data;

$end = $ptpl->utime();
$runtime = ($end - $start) * 1000;
echo "<br>Completed in $runtime miliseconds<BR>\n";

// we write the file at the end so this
// operation will not be counted in the benchmark
$ptpl->write_to_cache($data);
?>

 
  Advertise on this site Advertise on this site   Site map Site map   Statistics Statistics   Site tips Site tips   Privacy policy Privacy policy   Contact Contact  

For more information send a message to :
info at phpclasses dot org.
Copyright (c) Icontem 1999-2009 PHP Classes - PHP Class Scripts
  PHP Book Reviews - Reviews of books and other products