mardi 6 septembre 2016

Smarty if strlen < 0 not work propertly

I try show text if smarty variable string length is more then 0, so at first I dump this variable to see which products supposed to show me what I want.

{strlen($product.color_list)|var_dump}

and it give me for example:

product 1: int(20),
product 2: int(18),
product 3: int(0),
product 4: int(29),

Now I want to for every product with string length > 0 show text: Color!

{if $product.color_list|count_characters < 0}
<div class="color-text-container">Color!</div>
{else}
No color :(
{/if}

or:

{if strlen($product.color_list) < 0}
<div class="color-text-container">Color!</div>
{else}
No color :(
{/if}

or:

{if isset($product.color_list) && strlen($product.color_list) < 0}
<div class="color-text-container">Color!</div>
{else}
No color :(
{/if}

But always I got No color :( for every product, why?

Aucun commentaire:

Enregistrer un commentaire