Re: cacheing + resource errors
| From: | Rob Ellis | Date: | Thu, 05 Dec 2002 17:12:39 +0000 |
| Subject: | Re: cacheing + resource errors | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-6659@lists.php.net to get a copy of this message | ||
On Wed, Dec 04, 2002 at 11:56:25AM -0500, Rob Ellis wrote:
> I'm setting up a smarty resource where the xx_get_template() function
> gets a remote html page. Usually this works fine, but it
> could occasionally get nothing or get junk...
>
> What I'd like to do is look at the results of the file() call
> and have smarty fall back to using the cached copy of the resource
> if there's a problem. Is there a way to do this?
>
looking into this a little more, i find i can get the behaviour
i want with the little patch to Smarty that follows below... basically:
if the call to _process_template() fails,
include $_smarty_compile_path anyway
which makes it fall back to the cache.
i'm not recommending that this patch be used as is -- there's
probably a better way to do it; but i think there will be cases
(where a database isn't available, for instance) where you want
this behaviour (try to load a resource / fall back to the cache
if that fails).
?
- rob
--
Rob Ellis <rob@web.ca>
System Administrator, Web Networks
here's the patch...
--- Smarty.class.php- Wed Dec 4 11:29:27 2002
+++ Smarty.class.php Wed Dec 4 11:36:41 2002
@@ -1132,9 +1132,8 @@
array_unshift($this->_config, $this->_config[0]);
$_smarty_compile_path = $this->_get_compile_path($_smarty_include_tpl_file);
- if ($this->_process_template($_smarty_include_tpl_file, $_smarty_compile_path)) {
- include($_smarty_compile_path);
- }
+ $this->_process_template($_smarty_include_tpl_file, $_smarty_compile_path);
+ @ include($_smarty_compile_path);