Re: Please help on caching
| From: | Monte Ohrt | Date: | Thu, 27 Dec 2001 14:22:12 +0000 |
| Subject: | Re: Please help on caching | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-2387@lists.php.net to get a copy of this message | ||
Try a very simple test to see if the caching with a cache_id is working
at all.
index.php
---------
include("Smarty.class.php");
$tpl = new Smarty;
$tpl->caching=true;
$tpl->assign('foo','test1');
$tpl->display('index.tpl','a');
$tpl->assign('foo','test2');
$tpl->display('index.tpl','b');
index.tpl
---------
my var is {$foo}
Run this a few times, see if you get
my var is test1
my var is test2
If you do, then caching _should_ be working as expected, since the
content is different for each call to index.tpl. Also check that that
cache files are being created, and look at their content.
"Brian E. Lozier" wrote:
>
> I'm very frustrated right now because I can't get the caching to function correctly.
> I have a page called
> 'files.php' which is designed to list all files under a certain 'category.'
> These files and categories are
> stored in a database. Here is a small example of the category table.
>
> catID
> catName
> catParent
>
> This way I can have infinitely nested categories. So, if I want to view a specific category, I
> just view the
> page and pass a $catID in.
>
> files.php?catID=5
>
> Say this lists "Windows Text Editors."
>
> It defaults to '0' if no catID is passed correctly which will list just root
> categories.
>
> Now here is the problem. The cached results are ALWAYS the same as the very first access to
> the files.php
> page. So, if I access files.php?catID=5, it caches the results correctly for that catID (all
> the "Windows
> Text Editors"). The problem is, after that, if I pass another catID, I get the original
> cached results from
> $catID = 5 (Windows Text Editors).
>
> I have queried this list quite a few times but nothing is helping. I upgraded to the latest
> version. I have
> tried all suggestions. Is this a bug in Smarty? Does anyone else have this
> "dynamic" content caching
> correctly using the cache_id? Because Smarty is just ignoring my cache_id I pass, no matter
> what it is.
> Please, I really need to get this working, it's important.
>
> Here is my 'main.tpl' which is the main layout of the site (note I replaced > and
> < with ] and [ because my
> email program strips the HTML for some reason):
>
> main.tpl:
> [html]
> [head][title]{$PageTitle}[/title][/head]
> [body]
> {$Content}
> [/body]
> [/html]
>
> Then, my files.php functions like this:
> $tpl = new Smarty;
> // get all my db stuff into a few arrays
> // Assign all to Smarty like:
> $tpl->assign("Categories", $categories);
> $tpl->assign("Files", $files);
>
> // Then I include the specific template for the specific page I'm working on:
> $tpl->assign("Content", $tpl->fetch('files.tpl'));
>
> // Then I display it
> $tpl->display('main.tpl');
>
> I have tried passing both $REQUEST_URI (which *is* passing correctly, I verified!) and $catID
> (since it's
> unique for each of the cache results I'm looking for) to main.tpl like:
> $tpl->display('main.tpl', $REQUEST_URI); // and:
> $tpl->display('main.tpl', $catID);
>
> I've also tried passing it to the $tpl->fetch() where I get the actual files.tpl
> template like:
> $tpl->assign("Content", $tpl->fetch('files.tpl', $REQUEST_URI));
> $tpl->assign("Content", $tpl->fetch('files.tpl', $catID));
>
> But it never caches any differently, no matter what. Please, I really need some help. Thanks
> in advance.
>
> Brian
>
> ---
> You are currently subscribed to smarty as: monte@ispi.net
> To unsubscribe send a blank email to $subst('Email.Unsub')
> Visit Smarty's homepage at
> http://www.phpinsider.com/php/code/Smarty/
--
Monte Ohrt <monte@ispi.net>
http://www.ispi.net/