|
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 |
vbmali9191 Smarty n00b
Joined: 30 Jan 2018 Posts: 1
|
Posted: Tue Jan 30, 2018 5:37 am Post subject: whats the best practice or rule to write the if condition |
|
|
When I am writing my if block open and close in one line then it creates a problem while printing the variable, but not when I am using like this:
{if isset($title)}
{$title}
{/if}
Problem with:
{if isset($title)}{$title}{/if}
if I use the code in single line the variable prints unnecessary spaces at the end of string, I have tried by using strip and trim but no use.
What's the reason behind this problem? |
|
Back to top |
|
bsmither Smarty Elite
Joined: 20 Dec 2011 Posts: 322 Location: West Coast
|
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Tue Jan 30, 2018 4:29 pm Post subject: |
|
|
It may be not a space after variable, but a space after {/if}. |
|
Back to top |
|
crownclown67 Smarty Rookie
Joined: 03 May 2018 Posts: 12
|
Posted: Wed Aug 15, 2018 7:02 am Post subject: |
|
|
My question is:
Why You use {if isset($title)}{$title}{/if}
but not only this {$title} ? |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Wed Aug 15, 2018 11:43 am Post subject: |
|
|
{$title|default:''}
would be more appropriate to the present cause. |
|
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
|