|
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 |
maorbari Smarty Rookie
Joined: 27 Dec 2014 Posts: 10
|
Posted: Sat Dec 27, 2014 5:02 am Post subject: Smarty issue with {if} inside another tag |
|
|
I built plugin of create forms:
Code: | function smarty_function_form(array $parameters, Smarty_Internal_Template $smarty) {
$form = new Form($parameters);
$smarty->form_object = $form;
return $form->output_opentag();
} |
When I call it and use "if" tag inside, I am getting syntax error and "too many shorthand attributes" error.
I use it like that:
Code: | {form name="the_name" {if $var == 5}class="active"{/if} method="post" action=""} |
If I remove "if" tag it's working.
How to solve it? Thank you. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Sat Dec 27, 2014 10:27 am Post subject: |
|
|
Smarty tags can not be nested. |
|
Back to top |
|
maorbari Smarty Rookie
Joined: 27 Dec 2014 Posts: 10
|
Posted: Sat Dec 27, 2014 11:59 am Post subject: |
|
|
Do you have an alternatives? |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Sat Dec 27, 2014 2:38 pm Post subject: |
|
|
If you need to add parameters to your functions, do that in your function. |
|
Back to top |
|
maorbari Smarty Rookie
Joined: 27 Dec 2014 Posts: 10
|
Posted: Sat Dec 27, 2014 2:42 pm Post subject: |
|
|
What do you mean? |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Sat Dec 27, 2014 5:58 pm Post subject: |
|
|
I did in my first post not think of that you can use Smarty tags within double quoted strings.
So you could use something like this
Code: | {form name="the_name" class="{if $var == 5}active{/if}" method="post" action=""} |
|
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Sat Dec 27, 2014 11:27 pm Post subject: |
|
|
That's an… interesting way of doing it. |
|
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
|