Jump to content

Smarty and array_unique


Recommended Posts

Hey all,

 

I am by no means an advanced developer in PrestaShop, I am trying my best to learn but I'm stuck on something I hoped was a simple solution.

 

I am talking about the stores.tpl page, I'm using the simple mode where it outputs a list of all the store contacts.

 

I would like to divide these up by country and have the country as the title in <h2> tags and then the list of stores in that country then loop to the next country, I only require to use the $store.country value once. PHP offers a solution array_unique which would work but I'm not sure how to implement this into Smarty, perhaps I need to create a function to resolve this?

 

This is the current loop;

 

{foreach $stores as $store}

 <ul class="authorised-dealers">
 <li><h4>{$store.name|escape:'htmlall':'UTF-8'}</h4></li>
 <li>{$store.address1|escape:'htmlall':'UTF-8'}</li>
 <li>{if $store.address2}{$store.address2|escape:'htmlall':'UTF-8'}{/if}</li>
 <li>{$store.postcode} {$store.city|escape:'htmlall':'UTF-8'}{if $store.state}, {$store.state}{/if}</li>
 <li>{$store.country|escape:'htmlall':'UTF-8'}</li>
 <li>{if $store.phone}{l s='Phone:' js=0} {$store.phone}{/if}</li>

 <li>{if isset($store.working_hours)}{$store.working_hours}{/if}</li>
 </ul> 
{/foreach}

 

Any help would be awesome.

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...