Main function Description
Removed the functionality of the Discuz language pack
Porting all of the features in the Discuz template
Added automatic Update cache and lifecycle features
The use of the template in the same way as discuz, so do not make redundant instructions, before use only need to do some simple setup to
If you need to use Discuz's Language pack feature, just remove the template.class.php 172th comment and add discuz original Languagevar function in template.func.php.
Click to download the source file
Here's the code example:
/**
* Use Example
*
* @copyright Copyright (c) 2007-2008 (http://www.tblog.com.cn)
* @author Akon (tomato red)
* @license PHP Version 3.0 {@link Http://www.php.net/license/3_0.txt}
*/
Require_once (' classes/template.class.php ');
$options = Array (
Template_dir ' = ' templates/',//Specify template file to store directory
' Cache_dir ' = ' templates/cache ',//Specify cache file storage directory
' Auto_update ' + true,//regenerate cache when template file is changed [close this item will be faster]
' Cache_lifetime ' = 1,//Cache life cycle (minutes), 0 = permanent [set to 0 faster]
);
$template = Template::getinstance (); Instantiating a template class using a single-piece pattern
$template->setoptions ($options); Setting Template Parameters
/*
You can set parameters using the following three ways
$template->setoptions (Array (' template_dir ' = ' templates/default/')); Used for Batch setup
$template->set (' Template_dir ', ' templates/default/');
$template->template_dir = ' templates/default/');
*/
$TESTARR = Array (' testa ' = ' a ', ' testb ' = ' B ');
Include ($template->getfile (' test.htm '));
?>
The above describes the Discuz template Discuz template engine encapsulation class code, including the content of the Discuz template, I hope to be interested in PHP tutorial friends helpful.