Re: [SMARTY] How to now if fetch() failed ?
| From: | messju mohr | Date: | Thu, 04 Dec 2003 13:25:56 +0000 |
| Subject: | Re: [SMARTY] How to now if fetch() failed ? | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-10628@lists.php.net to get a copy of this message | ||
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
>