Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

is force_compile required to make (post|pre)filters work ?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
David
Smarty Rookie


Joined: 18 Apr 2003
Posts: 17
Location: New York, NY, USA

PostPosted: Wed Nov 05, 2003 7:51 pm    Post subject: is force_compile required to make (post|pre)filters work ? Reply with quote

I haven't been able to get any filters to work unless I either modify the templates or turn on force_compile.

This is with Smarty 2.5.0, PHP 4.3.2, Windows 2K -- though I get the same behavior on a Solaris box.

I've been trying this exercise, among other things:
Code:

function dog2cat($tpl_source) {
   
   return preg_replace("/dog/", "cat",$tpl_source);

}

ini_set("error_reporting",E_ALL);
$t->caching = 0;
$t->register_postfilter("dog2cat");
//$t->compile_check = 1;
// $t->force_compile = true;
$t->display("filter_test.html");

----------- here's the template. fwiw -----------

<p>
this is a sentence with the word dog as in D O G
</p>

------------------------------------------------------

I have tried as both a pre and post filter and it fails both ways, again, unless I either (1) touch the template or (2) set force_compile to true

Am I doing something wrong, or is this a bug, or is this a feature? Many TIA
_________________
David Mintz
http://davidmintz.org/

"Anybody else got a problem with Webistics?" -- Sopranos 24:17
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Wed Nov 05, 2003 8:32 pm    Post subject: Reply with quote

pre and post filters are applied only at template compile time, that is by design.
Back to top
View user's profile Send private message Visit poster's website
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Wed Nov 05, 2003 8:34 pm    Post subject: Reply with quote

Pre and Post filters are only run during the compilation process. If you have Smarty configured to recompile on template changes, then they would be invoked then.

Pre-filters: used to modify your template prior to compilation.
Post-filters: used to modify compiled code.

Finally:

output filters: used to modify the final sent content.

AFAIR, output filters are run every invocation of the page, so you probably want to try this one, depending on what you are trying to do.

HTH


Last edited by boots on Wed Nov 05, 2003 11:11 pm; edited 1 time in total
Back to top
View user's profile Send private message
David
Smarty Rookie


Joined: 18 Apr 2003
Posts: 17
Location: New York, NY, USA

PostPosted: Wed Nov 05, 2003 9:41 pm    Post subject: Reply with quote

Output filters ---- brilliant!

I see I should have RFTMed even more. Thank you. Case closed Smile
_________________
David Mintz
http://davidmintz.org/

"Anybody else got a problem with Webistics?" -- Sopranos 24:17
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP