PHP Classes
Icontem

File: 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 Andrey Nikishaev  >  Little PHP Templater  >  example.php  
File: example.php
Role: Example script
Content type: text/plain
Description: example
Class: Little PHP Templater
Template engine that caches output
 

Contents

Class file image Download
<?php

include_once('templater.php');

/*

new Template(dir1,dir2) - create templater.
    Dir1 - Dir for templates.
    Dir2 - Dir for cache.
    By default Dir1='templates/', Dir2='cache/'

is_cached(tpl_name,tpl_time,tpl_hash) - checks lifetime of cache
    tpl_name - name of the template, situated in Dir1.
    tpl_time - cache lifetime. tpl_time set to -1 it's means that cache never die. If 0 or nothing, it's means that there isn't any cache.
    tpl_hash - string for separate one cache from another. For example: you have 2 articles one in english and second in spanish. But they are use one template. So you just need ti write is_cached(tpl_name,tpl_time,"en") and is_cached(tpl_name,tpl_time,"sp").

assign(nave_of_variable,value_of_variable) - Sets variable to template

fetch(tpl_name,tpl_time,tpl_hash) - render template.
tpl_name - name of the template, situated in Dir1.
    tpl_time - cache lifetime. tpl_time set to -1 it's means that cache never die. If 0 or nothing, it's means that there isn't any cache.
    tpl_hash - string for separate one cache from another. For example: you have 2 articles one in english and second in spanish. But they are use one template. So you just need ti write fetch(tpl_name,tpl_time,"en") and fetch(tpl_name,tpl_time,"sp").


*/
$tpl=new Template();
if(!
$tpl->is_cached('a.tpl',300,'a')) {
echo 
"Cached";
$tpl->assign("agon","agon");
}
echo 
$tpl->fetch('a.tpl',300,'a');


 
  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