RE : [SMARTY] RE : [SMARTY] RE : [SMARTY] How to now if fetch() failed ?

From: Date: Thu, 04 Dec 2003 16:22:22 +0000
Subject: RE : [SMARTY] RE : [SMARTY] RE : [SMARTY] How to now if fetch() failed ?
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-10633@lists.php.net to get a copy of this message
Ok, I undestand. It was just a suggestion, your previous answer give me all the informations I was needed :) -----Message d'origine----- De : messju mohr [mailto:messju@lammfellpuschen.de] Envoyé : jeudi 4 décembre 2003 17:19 À : Christopher Rousseau Cc : smarty-general@lists.php.net Objet : Re: [SMARTY] RE : [SMARTY] RE : [SMARTY] How to now if fetch() failed ? i wouldn't add this to display(), only to fetch(). display() is for raw speed and nothing else. On Thu, Dec 04, 2003 at 03:19:38PM +0100, Christopher Rousseau wrote: > Hum, my bad, I didn't read completely the display() code: > My modification is not even bad, it's wrong :) > > It would be better to do only that : > Line 1157: return $this->fetch($resource_name, $cache_id, $compile_id, > true); > > Better then it work no ? :) > > -----Message d'origine----- > De : Christopher Rousseau [mailto:christopher.rousseau@rezotech.com] > Envoyé : jeudi 4 décembre 2003 15:05 > À : smarty-general@lists.php.net > Objet : [SMARTY] RE : [SMARTY] How to now if fetch() failed ? > > Thx, > I have implement this modification on my Smarty. Do you will keep this > modification in the next version of Smarty? > > If yes, I would propose to change the display() method also, to return > false if the fetch() failed. > I was looking to implement it like that: > Line 1157: > ---- > $html = $this->fetch($resource_name, $cache_id, $compile_id, true); > if ($html === false) return false > echo $html; > ---- > > But I would prefer using php5 and a try/catch implementation, cleaner, > faster :( > > -----Message d'origine----- > De : messju mohr [mailto:messju@lammfellpuschen.de] > Envoyé : jeudi 4 décembre 2003 14:26 > À : Christopher Rousseau > Cc : smarty-general@lists.php.net > Objet : Re: [SMARTY] How to now if fetch() failed ? > > fetch() should return false when the template is not found, IMHO. > > my proposed change for that: > > Index: Smarty.class.php > =================================================================== > RCS file: /repository/smarty/libs/Smarty.class.php,v > retrieving revision 1.465 > diff -u -r1.465 Smarty.class.php > --- Smarty.class.php 4 Dec 2003 11:37:26 -0000 1.465 > +++ Smarty.class.php 4 Dec 2003 13:24:54 -0000 > @@ -1249,7 +1249,7 @@ > } > } > > - $_smarty_compile_path = > $this->_get_compile_path($resource_name); > + if (! $_smarty_compile_path = > $this->_get_compile_path($resource_name)) return false; > > // if we just need to display the results, don't perform output > // buffering - for speed > > > > > On Wed, Dec 03, 2003 at 02:46:43PM +0100, Christopher Rousseau wrote: > > Hello all, > > > > > > > > I'm looking for a way to know then a $smarty->fetch() (or display) > > failed. > > > > I'm using dynamics templates in my own MVC framework and was looking > for > > a way to catch error during the fetch() command. > > > > My main purpose is to catch the 'Smarty error: unable to read > resource:' > > then Smarty don't find the template file. > > > > I would like to avoid to check the existence of the template before > > doing the fetch() to avoid duplicating what Smarty do internally. > > > > > > > > I did look at the Smarty code, but didn't see a good way to do it. > > > > Then the fetch() command failed, it return an empty string, but a > > template can also return an empty string. I didn't find if Smarty > > trigger an Internet error flag then an error occur (beside the > > trigger_error() call). > > > > > > > > By the way, thx for the job done with Smarty. I keep crying then I > have > > to change code made before using Smarty :-) > > > > > > > > Thx, > > > > Chris, > > > > www.rezotech.com > > > > -- > Smarty General Mailing List (http://smarty.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- > Smarty General Mailing List (http://smarty.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- Smarty General Mailing List (http://smarty.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

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