Jump to content

php loop


kia

Recommended Posts

I'm a beginner in prestashop, I'm overriding a module to make it look the way I want. I've done a basic loop but it display something I don't understand, I'm new with the prestashop code so if someone can show me my error it will help.

 

my loop

<!-- Block languages module -->

{if count($languages) > 1}

<div id="languages_block_top">

<div id="countries">

{* @todo fix display current languages, removing the first foreach loop *}

{foreach from=$languages key=k item=language name="languages"}

{if $language.iso_code == $lang_iso}

 

{$language.iso_code} |

 

{/if}

{/foreach}

{$i=0}

{foreach from=$languages key=k item=language name="languages"}

 

{if $language.iso_code != $lang_iso}

{assign var=indice_lang value=$language.id_lang}

{if isset($lang_rewrite_urls.$indice_lang)}

<a href="{$lang_rewrite_urls.$indice_lang|escape:htmlall}" title="{$language.name}">

{else}

<a href="{$link->getLanguageLink($language.id_lang)|escape:htmlall}" title="{$language.name}">

 

{/if}

{/if}

{if $language.iso_code != $lang_iso}

{$language.iso_code}</a>

{if ($i==1)} | {/if}

{/if}

{$i++}

{/foreach}

</div>

</div>

 

 

{/if}

 

<!-- /Block languages module -->

 

the outpout

en | fr 0 it | 1

 

my code is in red, I don't undertand why I see the number 0 and 1, I just want to display the | sign

 

thank you for your help

Link to comment
Share on other sites

Hi

 

In fact I think that smarty display {$i++}.

You want smarty to only post increment $i but you get both, post increment and display of $i value.

 

I think a smarty how to must done

 

A lame fix would be

<!-- {$i++}-->

 

But there must be other solutions

 

Have a good day

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...