0

Suggest me a better way to do it. I would like to show the array result in the horizontal manner.

Column1 | Column 2 | Column 3
3 | 7 | 10

now it shows in vertical manner as follows

Column1 | Column 2 | Column 3
3
7
10


Array Result : Stored in $result variable and assigned in smarty variable

Array
    (
        [0] => Array
            (
                [1] => 3
                [Value] => 3
            )
        [1] => Array
            (
                [1] => 7
                [Value] => 7
            )
        [2] => Array
            (
                [1] => 10
                [Value] => 10
            )
    )

.tpl code

<div>
    <ul>
       <li>Column1</li>
       <li>Column2</li>
       <li>Column3</li>
       <div class="clear"></div>
    </ul>

    {section name="index" loop=$result}
     <ul>                          
        <li>{$result[index].value}</li>
        <div class="clear"></div>
     </ul>
    {/section}
</div>
1
  • I think you should use a table structure instead of the ul structure to do this. Commented Jun 3, 2009 at 14:40

2 Answers 2

1

Put the UL out of your loop and make sure that LI's display is set to inline or float left.

<ul>
{section name="index" loop=$result}                     
   <li style="float:left;">{$result[index].value}</li>
{/section}
   <br style="clear:both" />
</ul>
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks Sleepycod. I tried. Yes the li is set to float:left and put the ul outside but same output.
{/section} (here) <-- Move your "<div class="clear"></div>" block here
0

Does this work?

<table>
 <tr>
  <th>Column1</th>
  <th>Column2</th>
  <th>Column3</th>
 </tr>

 <tr>
 {section name="index" loop=$result}
   <td>{$result[index].value}</td>
 {/section}  
 </tr>
</table>

Comments

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.