PHP Classes

File: xtemplate_ex5.php

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


Class file image Download
 * $Id: xtemplate_ex5.php,v 1.3 2000/07/16 19:33:46 jesus Exp $

	example 5
	demonstrates nullstrings

require "./xtpl.php";
require "./class.XTemplateAdaptor.php";
require "./class.CachedTemplate.php";

$xtpl=new CachedTemplate();

// for benchmarking
$start = $xtpl->utime();

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

	$xtpl->assign(INTRO_TEXT,"by default, if some variables weren't assigned a value, they simply disappear from the parsed html:");	

	$xtpl->assign(INTRO_TEXT,"ok, now let's assign a nullstring:");	
	$xtpl->SetNullString("value not specified!");

	$xtpl->assign(INTRO_TEXT,"custom nullstring for a specific variable and default nullstring mixed:");	
	$xtpl->SetNullString("no value..");
	$xtpl->SetNullString("no email specified!",EMAIL);
	$xtpl->assign(INTRO_TEXT,"custom nullstring for every variable:) .. you should get it by now. :P");	
	$xtpl->SetNullString("no email specified",EMAIL);
	$xtpl->SetNullString("no name specified",FULLNAME);
	$xtpl->SetNullString("no income?",INCOME);


// get parsed document
$data = $xtpl->getParsedDoc("main");

// output the page
echo $data;

// for benchmarking
$end = $xtpl->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
For more information send a message to info at phpclasses dot org.