|
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 |
temp Smarty n00b
Joined: 18 Apr 2005 Posts: 1
|
Posted: Mon Apr 18, 2005 11:11 pm Post subject: {dynamic} block and include vars |
|
|
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 |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Tue Apr 19, 2005 1:43 am Post subject: |
|
|
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 |
|
markwu Smarty Rookie
Joined: 28 Sep 2005 Posts: 6
|
Posted: Wed Sep 28, 2005 5:34 pm Post subject: |
|
|
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 |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Wed Sep 28, 2005 5:40 pm Post subject: |
|
|
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 |
|
markwu Smarty Rookie
Joined: 28 Sep 2005 Posts: 6
|
Posted: Thu Sep 29, 2005 6:47 am Post subject: |
|
|
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.
Regards, Mark |
|
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
|