Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.
too many shorthand attributes for {if}{/if} blocks?

 
Post new topic   Reply to topic    Smarty Forum Index -> Feature Requests
View previous topic :: View next topic  
Author Message
ksnyde
Smarty Rookie


Joined: 19 Oct 2012
Posts: 12

PostPosted: Thu Jan 03, 2013 3:06 pm    Post subject: too many shorthand attributes for {if}{/if} blocks? Reply with quote

I have a simple Smarty template that checks for the existence of a number variables that it assumes may have been passed in by the calling template but if not set then defaults them to something appropriate. Here's the code:

Code:
{* DEFAULTS *}
{if not isset($field_id)}
   {$field_id="form-button-action"}
{/if}
{if not isset($field_name)}
   {$field_name="Submit"}
{/if}
{if not isset($btn_type)}
   {$btn_type="success"}
{/if}
{if not isset($action_btn_text)}
   {$action_btn_text=$field_name }
{/if}
{if no isset($action)}
   {$action="ajax-submit::{$action_btn_text}"}
{/if}
{if no isset($target)}
   {$target='body'}
{/if}


It was working but I added a few more and now I get the message
Quote:
Syntax Error in template ... on line 28 "{if no isset($action)}"; too many shorthand attributes


I'm not sure I understand what this really means in this case. Is there a limited to how many {if}{/if} blocks a template can have? I have tried removing each one-by-one, and then a few at a time. It does work if I remove the test for $action and $target but I just remove two others at random (testing the idea that its the number of conditional blocks) it doesn't appear to work. Strange.
Back to top
View user's profile Send private message
ksnyde
Smarty Rookie


Joined: 19 Oct 2012
Posts: 12

PostPosted: Thu Jan 03, 2013 3:13 pm    Post subject: Reply with quote

Ok, I'm an idiot. It had to do with the last two blocks having a "no" instead of "not" operator. Jeez. Still interested in what this error means so I can become more knowledgable but consider this problem solved.

Rolling Eyes
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Thu Jan 03, 2013 4:34 pm    Post subject: Reply with quote

In many cases Smarty tags accept unnamed attributes (shorthands).
For example the shorthand for {include file='foo.tpl'} is {include 'foo.tpl'}.

In your case the unknown 'no' caused the misleading error message.
Back to top
View user's profile Send private message
ksnyde
Smarty Rookie


Joined: 19 Oct 2012
Posts: 12

PostPosted: Thu Jan 03, 2013 5:51 pm    Post subject: Reply with quote

Thanks @U.Tews.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Feature Requests 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