Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

assign to variable cached value

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Feature Requests
View previous topic :: View next topic  
Author Message
wACKY
Smarty n00b


Joined: 12 Oct 2011
Posts: 1

PostPosted: Wed Oct 12, 2011 10:31 am    Post subject: assign to variable cached value Reply with quote

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
View user's profile Send private message
rodneyrehm
Administrator


Joined: 30 Mar 2007
Posts: 674
Location: Germany, border to Switzerland

PostPosted: Wed Oct 12, 2011 10:46 am    Post subject: Reply with quote

Corresponding question at Stack Overflow Need trick to use cached value in nocache section
_________________
Twitter
Back to top
View user's profile Send private message Visit poster's website
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Fri Oct 14, 2011 1:42 am    Post subject: Reply with quote

This will be implemented in Smarty 3.2.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Feature Requests All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP