Re: [SMARTY-DEV] clear_compiled_tpl() bug or missing feature

From: Date: Mon, 10 Nov 2003 10:35:30 +0000
Subject: Re: [SMARTY-DEV] clear_compiled_tpl() bug or missing feature
References: 1 2 3 4 5  Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-1921@lists.php.net to get a copy of this message
Monte Ohrt <monte@ispi.net> wrote: > This function would have to be run manually after an upgrade of > smarty, > I'm not sure what advantage this has over just removing the files from > template_c and cache files. > Or by extending Smarty. Maybe it could be used as an example for the docs of how to intergrade Smarty into an application Greetings, Jan Rosier * It is impossible to make anything foolproof, because fools are so ingenious. *

<?php /** * Template object... * http://smarty.php.net/ */ require_once 'Smarty/2.5.0/Smarty.class.php'; class Smarty_Extension extends Smarty { /** * The directory where compiled templates are located. * * @var string */ var $compile_dir = '/path/to/templates_c'; /** * The directory where config files are located. * * @var string */ var $config_dir = ''; /** * The name of the directory where templates are located. * * @var string */ var $template_dir = '/path/to/templates'; /** * An array of directories searched for plugins. * * @var array */ var $plugins_dir = Array('plugins', '../plugins'); /** * The left delimiter used for the template tags. * * @var string */ var $left_delimiter = '<!--{'; /** * The right delimiter used for the template tags. * * @var string */ var $right_delimiter = '}-->'; /** * This tells Smarty whether or not to use sub dirs in the cache/ and * templates_c/ directories. sub directories better organized, but * may not work well with PHP safe mode enabled. * * @var boolean */ var $use_sub_dirs = FALSE; /** * Constructor * * @access public * * @param array $options * * @return void */ function Smarty_Extension($options = Array()) { $this->Smarty(); foreach ($options as $key => $value) { $this->$key = $value; } $this->clear_invalid_files(); } /** * This method check the current version of Smarty. On different * versions the compiled and cached templates are deleted. * * @access public */ function clear_invalid_files() { $fname = $this->compile_dir . '/.version-' . $this->_version; if (!file_exists($fname)) { $this->clear_all_cache(); $this->clear_compiled_tpl(); touch($fname); } } } $smarty = new Smarty_Extension; ?>
« previous php.smarty.dev (#1921) next »