0

am making sitemap for my website which is multi language.

my current sitemap code looks like

{foreach from=$data.listings_en item=i}
<url>
<loc>{$i}</loc>
</url>
{/foreach}

it was only for english urls which was ok now am trying to add few other language with it but am not able to it as i do not how to pass three arrays to above foreach loop

three arrays i have

$data.listings_en
$data.listings_cn
$data.listings_ru

values in $data.listings_en

$listings_en[] = 'my link 1';

$data['listings_en']    = $listings_en;

what i want something like that

    {foreach from=$data.listings_en item=i}   // loop over three arrays all arrays have same size
    <url> 
    <loc>{$i}</loc>   // print url of listening_en 
 <loc>{$i}</loc>    // print url of listening_cn 
 <loc>{$i}</loc>  // print url of listening_ru 
    </url>
    {/foreach}
4
  • Do you really need all the languages in one template? Or one language per template? Commented Feb 26, 2016 at 9:40
  • How you are string values in $data.listings_en. Simple string or string in array? Commented Feb 26, 2016 at 9:41
  • @Sougata question updated . values in $data.listings_en are string in array Commented Feb 26, 2016 at 9:54
  • Do - $data['listings_en'] = 'my link 1'; & loop through $data only. I hope it will solve the problem. Commented Feb 26, 2016 at 9:55

1 Answer 1

1
{foreach from=$data item=i} <li>{$i}</li>{/foreach}
Sign up to request clarification or add additional context in comments.

2 Comments

$data have three arrays listings_ru , en and cn .... so how single $i will work ... i want three print in loop
{foreach from=$data item=i} <li>{$i.listings_en}</li><li>{$i.listings_cn}</li><li>{$i.listings_ru}</li>{/foreach} it is not too clear because it depends on the next smarty what you asssignné $ smarty-> assign ( 'myArray', $ arr);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.