Location: PHPKode > scripts > Template Processor > template-processor/example_loading.php
<?php
	/**
	 * Load class
	 */
	require_once("./template.class.php");

	/**
	 * Make object instance
	 */
	$temp = new Template();

	/**
	 * When loading templates you can sepcify 2 new options 
	 * using the set_option()
	 *
	 * CWD means Current Working Directory and in this case 
	 * you define the root directory of where you want to 
	 * load the templates using load() with a given extension
	 *
	 * 	Note. The default extension is 'html'
	 *
	 */
	$temp->set_option('cwd', './');
	$temp->set_option('ext', 'php');

	/**
	 * Loading a template, you can set the 3rd parameter to 
	 * true, if you wanna ingore the given CWD option!
	 *
	 * 	$temp->load('template');
	 *
	 * The above example load the file:
	 *
	 *	./template.php
	 *
	 * In relative path to the real CWD
	 *
	 * This will load the file:
	 *
	 *	template.php
	 *
	 * Since the CWD was ingored.
	 *
	 * 	$temp->load('template', false, true);
	 *
	 * Right, so now the cache is populated with the content from 
	 * the template file, if you have turned on the option 'usetempinfo'
	 * you can see a small detailed description of all files you have 
	 * loaded in this instance before you destroy it!
	 *
	 * Now lets check if our file exists before starting:
	 */
	if(!$temp->exists('template'))
	{
		/**
		 * Notice that we ain't use $temp->error() here, look at the 
	 	 * next example for more information about error handling using 
	 	 * the class
		 */
		die("Template does not exists!");
	}

	/**
	 * Load it into cache, if you're trying to load a non-existing template
	 * then you'll get an error though $temp->error(), so thats why we did 
	 * as above in this example!
	 */
	$temp->load('template');

	/**
	 * Now we have it we can do whatever we like and then compile it ...
	 */
	$temp->compile();

	/**
	 * For more information about the parameters Template::load() accepts
	 * then read the comment in the class file for more information and 
	 * abit more description
	 */
?>
Return current item: Template Processor