Please help on caching
| From: | Brian E . Lozier | Date: | Thu, 27 Dec 2001 00:06:01 +0000 |
| Subject: | Please help on caching | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-2383@lists.php.net to get a copy of this message | ||
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