Re: [SMARTY] cache+dynamic site - i don't get it...

From: Date: Thu, 02 May 2002 04:53:22 +0000
Subject: Re: [SMARTY] cache+dynamic site - i don't get it...
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-3971@lists.php.net to get a copy of this message
That is what is_cached is for. you put is_cached around your db calls. If the page is cached, then don't execute the db calls. Monte k wrote:
[posted this to the php.smarty.general newsgroup, but did not show up - but sorry if it shows up two times] Hi, I have started using Smarty a few days ago. I've used PHP and other template systems before. So - I think - I've understood the main concept of Smarty, and I can create pages with templates. My problem is that I don't understand the "relation" of the cache feature and dynamic content. The way I use Smarty now is the following: 1. gather data from database(s), put it in arrays, etc. 2. assign data to Smarty/template variables [assign()] 3. use display() to send the html out. My question: if I turn caching on, the 1st step above (get data from mysql database, put it in arrays, etc) will still be executed? (My goal is to run this part only once, only when data has changed.) If it's still executed, how sould I write the code, to avoid redundant db access? I know I can give a cache ID to the display() function, based on the GET vars (query_string), I've found the "insert" function (and use it for the banner), but things just don't come together in my head :O [A few notes about my site. I hope You don't mind if I explain it's structure a bit... I. static header II. a box with list of various items (names + values) III. search form + search result box IV. static footer I. and IV. are OK, these are in header and footer.tpl. II. contains data that only changes a few times in a month. So I really don't want to generate it on every visit (pageview). I was thinking about generating it with another script, and use it as a (sub)template, but that would not be the "Smarty way". III.: search results and detailed information. This part can change with every pageview. So, this site is something like a link-index page: you can click on categories, than you get the links in that category, and you can view the description of an item with another click. Category names don't change every day (but change sometimes), OTOH the results box have to be generated on the fly.] TIA, and excuse me for the long post. regards, k


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