views:

54

answers:

1

Hello all,

I have list of categories that is contained in li's on one column of my page (side bar). I now want it to span the whole width of the page in several columns. I would always like 3 or 4 columns to fit the page. This is the code that generates the one column.

        <div id="sidebar">
            <ul>
                {insert name=get_audio_categories assign=listcats}
                {section name=o loop=$listcats}
                <li><a href="{$baseurl}/z/{$listcats[o].CATID}/1/{$listcats[o].name}">{$listcats[o].name|stripslashes}</a> ({insert name=audio_categories_count value=a assign=atotal catid=$listcats[o].CATID}{$atotal} {$lang875}) </li>
                {/section}
            </ul>
        </div>

I have asked a similar question before but this was using pure php and table layouts. I can't seem to extract this logic below and apply to the above smarty tpl file:

$nbCols = 4;
$nbRows = count($indexes)/$nbCols;
for($row=0; $row<$nbRows; $row++) {
    echo "<tr>";
    for($i=0; $i<$nbCols; $i++) {
        $index = $indexes[$row + ($i*$nbRows)];
        echo "<td>$index</td><td><input id='$index' name='$index' type='checkbox' /></td>";
    }
    echo "</tr>";

I can get the total number of categories.

Thanks all for any help.

+1  A: 

Make use of the foreach build in function of Smarty to display the column.

Example can be found here http://www.smarty.net/manual/en/language.function.foreach.php

All you would need from your PHP code is an array that hold the information that you would like to display. It is very much like how you use the section function.

Ken Thai