Re: [SMARTY] [Beginner] How to use prefilters ?

From: Date: Fri, 17 Oct 2003 16:13:33 +0000
Subject: Re: [SMARTY] [Beginner] How to use prefilters ?
References: 1 2  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-10371@lists.php.net to get a copy of this message
Monte, I'm sorry to upset with this stupid problem but I still fail : Fatal error: Smarty error: [plugin] prefilter 'literalScriptAndStyle' is not implemented in f:\easyphp\www\PATH_TO\Smarty.class.php on line 1895 Is there somewhere a complete example or a tutorial on prefilter use ? Luc At 17:10 17/10/2003, Monte Ohrt wrote:
Use this to register the prefilter: $smarty->register_prefilter('literalScriptAndStyle'); On Fri, 2003-10-17 at 09:56, Luc Saint-Elie wrote: Heelo, In order to try Remy Dufour code, I'm trying to use prefilter what I've never done before. I have in smarty_dir/extraplugins/utils the file prefilter.literalScriptAndStyle.php This file is (Remy's code) : <?php /* * Smarty plugin * -------------------------------------------------------------
  * File:     prefilter.literalScriptAndStyle.php
  * Type:     prefilter
  * Name:     literalScriptAndStyle
* Purpose: Add {literal} to style and script tags. * ------------------------------------------------------------- */ function smarty_prefilter_literalScriptAndStyle(&$tpl_source, &$smarty) {
         //  <javascript>
         $pattern[] = '~<script\b(?![^>]*smarty)(.*)</script>~iU';
         $replace[] = '<!--{literal}--><script$1>$2</script><!--{/literal}-->';
         // <style>
         $pattern[] = '~<style\b(?![^>]*smarty)(.*)</style>~iU';
         $replace[] = '<!--{literal}--><style$1>$2</style><!--{/literal}-->';
         return  preg_replace($pattern, $replace, $tpl_source);
} // function ?> I have a smarty.config.php file containing // VARIOUS DEFINE.... Class My_Smarty extends Smarty { /**
    * Constructor
    **/
         function My_Smarty ()
         {
         $this->use_sub_dirs      = true;
         $this->compile_check    = true;
         $this->debugging        = false;
         $this->debugging_ctrl   = 'NONE';
         $this->caching          = false;
         $this->template_dir     = _APPLIPATH.'/templates';
         $this->compile_dir      = _SMARTYPATH.'/templates_c';
         $this->config_dir       = _SMARTYPATH.'/configs';
         $this->cache_dir        = _SMARTYPATH.'/cache';
         $this->debug_tpl        = _SMARTYPATH.'/debug.tpl';
         $this->cache_lifetime   = 3600;
         $this->plugins_dir = Array('plugins',
                                   'extraplugins/rss',
                                    'extraplugins/utils');
$this->register_prefilter('smarty_prefilter_literalScriptAndStyle');
         }
} Result : Fatal error: Smarty error: [plugin] prefilter 'smarty_prefilter_literalScriptAndStyle' is not implemented in f:\easyphp\www\musiquemag_01\include\smarty\Smarty.class.php on line 1895 I tried to place $smarty->register_prefilter('smarty_prefilter_literalScriptAndStyle'); in my index.php file <?php session_start(); include 'include/smarty.config.php'; $smarty = new My_Smarty; $smarty->register_prefilter('smarty_prefilter_literalScriptAndStyle'); ..... With the same result Luc


« previous php.smarty.general (#10371) next »