|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
wACKY Smarty n00b
Joined: 12 Oct 2011 Posts: 1
|
Posted: Wed Oct 12, 2011 10:31 am Post subject: assign to variable cached value |
|
|
Hi
{assign var="key" value=$rec@key cached}
It will be easier to explain by example:
In foreach, when nocache section appear, possibility assign @KEY to a variable, but as cached/const. Value should be evaluated during cache creation and kept as const.
Something like this:
test.tpl:
Code: |
{foreach $array as $rec}
{if $rec.dynamic}
{nocache}
{assign var="key" value=$rec@key cached}
{$array[$key].text}
{/nocache}
{else}
{$rec.text}
{/if}
{/foreach}
|
So i'm able to pass single array with some "configuration" with selective caching.
test.php:
Code: |
<?php
include_once 'libs/Smarty.class.php';
$smarty=new smarty();
$smarty->caching=1;
$smarty->assign('array',array(
'r1'=>array('dynamic'=>true,'text'=>'dynamic'),
'r2'=>array('dynamic'=>false,'text'=>'static')
));
$smarty->display('test.tpl');
|
|
|
Back to top |
|
rodneyrehm Administrator
Joined: 30 Mar 2007 Posts: 674 Location: Germany, border to Switzerland
|
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Fri Oct 14, 2011 1:42 am Post subject: |
|
|
This will be implemented in Smarty 3.2. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|