Re: new cache use suggestion

From: Date: Thu, 27 Mar 2003 13:20:42 +0000
Subject: Re: new cache use suggestion
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-8939@lists.php.net to get a copy of this message
Is what you mean we can do something as simple as :: {include file="header.html" cache='always'} {include file="stats.html" cache='never'} {include file="stats.html" cache='timed' cachelife="n"} {include file="footer.html" cache='always'} Pete Jindřich Šaršon wrote:
Hi, Yesterday I looked to cache system used in Smarty. But it only allows to cache whole pages, but I need to cache part of pages (in facts some include templates included from main page). So that I looked to Smarty.class file and I made easy sollution to use my favourite chache system. I use one main template for every page, that loads parts of page from other templates. It looks like: main.tpl: {include file="header.tpl"}
         blah blah main page
{include file="module_with_most_readed_articles.tpl"} {include file="footer.tpl} In this example I use header and footer, that is nothing special. But I also include box with most readed articles. But how to do not to read info about articles everytimes and cache it? I made some "hack" to smarty, so that it is done (I can send sources, if anybody will want): is php - test, if cache exist ($smarty->is_cached), generate cache ($smarty->cache = true;$smarty->fetch('module_with_most_readed_articles.tpl'), that will generate cage to cache directory. Now, I have to read cache in tpl file. I made plugin, named "cache", that has same syntax, as include, but instead of include and process template it simply include generated cache file (using 'private' smarty function '_read_cache_file'. It works well. I know, that it is hack, but I think, that it is good suggestion to support this use of cache in future version of smarty. Maybe it will be better to enhance include tag instead of create new 'cache' tag to handle cached templates. Have a nice day,
      Jindrich Sarson


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