Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7579049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:34:45+00:00 2026-05-30T17:34:45+00:00

I want to iterate thru single array and disable caching only for some elements.

  • 0

I want to iterate thru single array and disable caching only for some elements.
So my idea was to keep key and get element by key in nocache section. Unfortunatelly i haven’t found any possibility to:

assign cached $rec@key in nocache section,

or keep variable key definition in cached section.

Is there any way (without smarty code modification) to do it ?
here my test.tpl:

{foreach $array as $rec}
  {if $rec.dynamic}
    {assign var="key" value=$rec@key} 
    {nocache}
      {$array[$key].text}
    {/nocache}  
  {else}
    {$rec.text}
  {/if}
{/foreach}

and test.php:

<?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');

(of course i will use it for much more complicated things than text display:) )
I tried lot of tricks and by myself i think it is not possible, please tell me i am wrong 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T17:34:46+00:00Added an answer on May 30, 2026 at 5:34 pm

    What you are trying to accomplish is, as of Smarty 3.1.x, not possible. With 3.2 Smarty will allow you to “export” values into a {nocache} section to ensure they’re available when the template is re-executed.

    Until 3.2 is released (don’t ask for a date, I don’t know) you may be able to do this yourself using a compiler function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to get all events from all calendars, how do i iterate thru
I want to iterate over a list of DOM elements (check boxes) and keep
I want to iterate over the line elements. Each line element has item elements
I want to iterate through a table/view and then kick off some process (e.g.
I want to iterate over a sequence in xquery and grab 2 elements at
I want to iterate over an array of inputs that belong to certain class
I want to iterate over each line in the output of: ls -l /some/dir/*
I want to iterate through an array of objects <% @users.each do |user| %>
I want to iterate to get into every content in following Dictionary. private Dictionary<Subject,
I currently want to iterate over an array of Objects (2 properties: id &

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.