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

{dynamic} block and include vars

 
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 -> General
View previous topic :: View next topic  
Author Message
temp
Smarty n00b


Joined: 18 Apr 2005
Posts: 1

PostPosted: Mon Apr 18, 2005 11:11 pm    Post subject: {dynamic} block and include vars Reply with quote

I'm having a little trouble with the {dynamic} block found in the documentation. I have a super-template that calls a sub-template like:

{include file="myfile.tpl" var1=$varVal}

Inside myfile.tpl, I have a block of code that is dynamic, like:
{dynamic} This is dynamic {$var1} {/dynamic}

The strange thing is that $varVal is only echoed the FIRST time the page is compliled/cached, but not on subsequent page requests. The super template has no trouble echoing $varVal on subsequent loads, so I know it's not a problem with variable assignment. I'm stumped.

Any ideas?

Thanks!
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Tue Apr 19, 2005 1:43 am    Post subject: Reply with quote

think of {$var1}like <?php echo $var1; ?>

Therefore when the page is cached, there is no variable passed into the dynamic function, so there is no variable to echo.
Back to top
View user's profile Send private message Visit poster's website
markwu
Smarty Rookie


Joined: 28 Sep 2005
Posts: 6

PostPosted: Wed Sep 28, 2005 5:34 pm    Post subject: Reply with quote

mohrt wrote:
think of {$var1}like <?php echo $var1; ?>

Therefore when the page is cached, there is no variable passed into the dynamic function, so there is no variable to echo.


Hi mohrt:

Ah.. I face the same problem..

Do you have any ideas to work around this? For example, use session/cookie to keep the value of $var1?

Mark
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Wed Sep 28, 2005 5:40 pm    Post subject: Reply with quote

http://smarty.php.net/manual/en/caching.cacheable.php

Note the portion on "cache_attrs". It is a limited solution but you should be able to use it to help you in your situation. Worst-case, you can write a custom plugin that retireves values from the application and is called from the dynamic block.
Back to top
View user's profile Send private message
markwu
Smarty Rookie


Joined: 28 Sep 2005
Posts: 6

PostPosted: Thu Sep 29, 2005 6:47 am    Post subject: Reply with quote

boots wrote:
http://smarty.php.net/manual/en/caching.cacheable.php

Note the portion on "cache_attrs". It is a limited solution but you should be able to use it to help you in your situation. Worst-case, you can write a custom plugin that retireves values from the application and is called from the dynamic block.


Hi boots:

Many thanks. I will try to do some test with it. Smile

Regards, Mark
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 -> General 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