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

Smarty issue with {if} inside another tag

 
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
maorbari
Smarty Rookie


Joined: 27 Dec 2014
Posts: 10

PostPosted: Sat Dec 27, 2014 5:02 am    Post subject: Smarty issue with {if} inside another tag Reply with quote

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
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Sat Dec 27, 2014 10:27 am    Post subject: Reply with quote

Smarty tags can not be nested.
Back to top
View user's profile Send private message
maorbari
Smarty Rookie


Joined: 27 Dec 2014
Posts: 10

PostPosted: Sat Dec 27, 2014 11:59 am    Post subject: Reply with quote

Do you have an alternatives?
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Sat Dec 27, 2014 2:38 pm    Post subject: Reply with quote

If you need to add parameters to your functions, do that in your function.
Back to top
View user's profile Send private message
maorbari
Smarty Rookie


Joined: 27 Dec 2014
Posts: 10

PostPosted: Sat Dec 27, 2014 2:42 pm    Post subject: Reply with quote

What do you mean?
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Sat Dec 27, 2014 4:35 pm    Post subject: Reply with quote

http://www.smarty.net/docs/en/plugins.functions.tpl
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Sat Dec 27, 2014 5:58 pm    Post subject: Reply with quote

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
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Sat Dec 27, 2014 11:27 pm    Post subject: Reply with quote

That's an… interesting way of doing it.
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