|
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 |
gnudiff Smarty n00b
Joined: 11 May 2004 Posts: 2
|
Posted: Tue May 11, 2004 12:09 pm Post subject: Accessing array template vars smartly in plugin? |
|
|
When you pass an array to smarty via assign(), it understands the "." notation, namely:
[php:1:b53d6a3681]<?php
$smarty->assign( 'foo', array( 'bar' => 1, 'gazonk' => 2));
?>[/php:1:b53d6a3681]
and you can refer to it from template by:
Code: | <input type="text" name="foo.bar" value="{$foo.bar}"> |
will output: <input ... value="1"> into resulting HTML page.
Now, if I write a plugin, and I want to access foo.bar from within plugin func, it seems I can't use:
[php:1:b53d6a3681]<?php
function smarty_function_myfunc($params, &$smarty)
{
...
$smarty->get_template_vars('foo.bar'); // gives NULL
}
instead I have to use:
$smarty->get_template_vars('foo'); //gives array
?>[/php:1:b53d6a3681]
And do my own processing on the array. That is rather dumb -- can I have get the value of "foo.bar" directly somehow using the existing smarty parsing? |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Tue May 11, 2004 1:21 pm Post subject: Re: Accessing array template vars smartly in plugin? |
|
|
gnudiff wrote: | That is rather dumb -- can I have get the value of "foo.bar" directly somehow using the existing smarty parsing? |
no.
why don't you just pass $foo.bar as an attribute's value to the plugin? |
|
Back to top |
|
gnudiff Smarty n00b
Joined: 11 May 2004 Posts: 2
|
Posted: Tue May 11, 2004 1:40 pm Post subject: Re: Accessing array template vars smartly in plugin? |
|
|
messju wrote: |
why don't you just pass $foo.bar as an attribute's value to the plugin? |
because what i want to do is something like:
{checkbox name="foo.bar" }
so i don't have to write:
<input type="checkbox" name="foo.bar" {if $foo.bar=='Y' }checked{/if} > |
|
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
|