[prev in list] [next in list] [prev in thread] [next in thread] 

List:       smarty-dev
Subject:    Re: [SMARTY-DEV] clear_compiled_tpl() bug or missing feature
From:       "Jan Rosier / Interstroom" <rosier () interstroom ! nl>
Date:       2003-11-10 10:35:30
[Download RAW message or body]

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. *

["example.txt" (text/plain)]

<?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;

?>


-- 
Smarty Development Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic