|
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 |
gremio10 Smarty Rookie
Joined: 28 Jan 2011 Posts: 11
|
Posted: Fri Mar 25, 2011 1:53 am Post subject: Problems with {if} |
|
|
Hey guys, I had a problem here, look:
Code: | Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template "views\index.tpl" on line 17 "{if $product.promotional_value != 0 }" - Unexpected " }"' in C:\xampp\htdocs\fofurinha\Smarty\libs\sysplugins\smarty_internal_templatecompilerbase.php:431 Stack trace: #0 C:\xampp\htdocs\fofurinha\Smarty\libs\sysplugins\smarty_internal_templateparser.php(2855): Smarty_Internal_TemplateCompilerBase->trigger_template_error() #1 C:\xampp\htdocs\fofurinha\Smarty\libs\sysplugins\smarty_internal_templateparser.php(2920): Smarty_Internal_Templateparser->yy_syntax_error(10, ' }') #2 C:\xampp\htdocs\fofurinha\Smarty\libs\sysplugins\smarty_internal_smartytemplatecompiler.php(51): Smarty_Internal_Templateparser->doParse(10, ' }') #3 C:\xampp\htdocs\fofurinha\Smarty\libs\sysplugins\smarty_internal_templatecompilerbase.php(82): Smarty_Internal_SmartyTemplateCompiler->doCompile('{include file="...') #4 C:\xampp\htdocs\fofurinha\Smarty\libs\sysplugins\smarty_internal_template.php(260): Smarty_Internal_Template in C:\xampp\htdocs\fofurinha\Smarty\libs\sysplugins\smarty_internal_templatecompilerbase.php on line 431 |
my code:
Code: | {include file="header.tpl"}
<div id="produtos">
<h1>em destaque:</h1>
<ul id="product">
{foreach from=$products item="product"}
<li>
<a href="{$url}detail/{$product.id}">
<div class="name">
{$product.name}
</div>
<img src="{$url}manager/imgs/{$product.image}" alt="" width="240" height="195" />
<div id="description-detail">
{$product.description|truncate:30:"...":true}
</div>
<div id="price">
{if $product.promotional_value != 0 }
<div class="price-promotion">
De: R$ <s>{$product.price}</s>
</div>
Por: R$ {$product.promotional_value}<br />
<div class="or">
ou <b>{$product.parcela}x</b> de <b>R$ {$product.promotional_value / $product.parcela|number_format:2:",":"."}</b>
</div>
{else}
Por: R$ {$product.price}<br />
<div class="or">
ou <b>{$product.parcela}x</b> de <b>R$ {$product.price / $product.parcela|number_format:2:",":"."}</b>
</div>
{/if}
</div>
</a>
</li>
{/foreach}
</ul>
</div>
{include file="footer.tpl"} |
my array:
Code: | Array
(
[0] => Array
(
[id] => 11
[name] => window
[description] => heheheh
[price] => 190.00
[promotional_value] => 167.00
[delivery_time] => 10
)
[1] => Array
(
[id] => 12
[name] => Tulipas
[description] => é uma tulipa de crochê
[price] => 12.90
[promotional_value] => 10.99
[delivery_time] => 1
)
[2] => Array
(
[id] => 15
[name] => my name
[description] => huahhsuahsauhsuahjnjNJHSAUSYAGYSGA
[price] => 788.00
[promotional_value] => 456.00
[delivery_time] => 10
)
) |
Thank you |
|
Back to top |
|
thesame Smarty n00b
Joined: 23 Mar 2011 Posts: 3
|
Posted: Fri Mar 25, 2011 5:49 am Post subject: |
|
|
Do you have $auto_literal True or False? |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Mar 25, 2011 5:51 am Post subject: |
|
|
The error tells you exactly the problem:
Code: | {if $product.promotional_value != 0 }" - Unexpected " }" |
change to 0} (no space) |
|
Back to top |
|
gremio10 Smarty Rookie
Joined: 28 Jan 2011 Posts: 11
|
Posted: Fri Mar 25, 2011 11:28 am Post subject: |
|
|
mohrt wrote: | The error tells you exactly the problem:
Code: | {if $product.promotional_value != 0 }" - Unexpected " }" |
change to 0} (no space) |
Thanks, works |
|
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
|