Re: [SMARTY] Cached data in random blocks?
| From: | Monte Ohrt | Date: | Tue, 18 Jun 2002 13:28:58 +0000 |
| Subject: | Re: [SMARTY] Cached data in random blocks? | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-4923@lists.php.net to get a copy of this message | ||
There are lots of ways to accomplish this. I suppose you could use Smarty's cache and fetch each block individually like so:
$order = array(2,4,1,3); // randomize this each time
$smarty->assign('block1',$smarty->fetch('block',$order[1]));
$smarty->assign('block2',$smarty->fetch('block',$order[2]));
$smarty->assign('block3',$smarty->fetch('block',$order[3]));
$smarty->assign('block4',$smarty->fetch('block',$order[4]));
$smarty->display('index.tpl');
index.tpl
---------
{$block1}
{$block2}
{$block3}
{$block4}
You may have to do a little more work like checking for expired caches, but the idea is there.
Monte
Eskil Keskikangas wrote:
I want to display a page with some data from the databas. The data is displayed in four blocks: [block1][block2] [block3][block4] My problem is that I want to display the blocks in random order without having to do the database query more than once. Any suggestions how I can solve this? BG Eskil