For Programmers: Free Programming Magazines  


Home > Archive > PHP Smarty Templates > January 2005 > Re: [SMARTY] alphabetically down columns in a table









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [SMARTY] alphabetically down columns in a table
Abdul-Wahid Paterson

2005-01-11, 4:00 pm

Hi,

Ok, I came up with this solution which works fine for me. Thanks to
all who gave help with this and the array counting part.

I basically have an array called $data and a $numcols,....That in my
case my users are defining within their template.

Here is my template...cut down a bit to simplifiy the example

<table>
{math equation="count/$numcols" count=$data|@count assign=length}
{section name=data1 loop=$data step=$numcols}
<tr>
{section name=data2 loop=$data step=$length
start=$smarty.section.data1.iteration}
<td><a href="sompage.php?data={$data[data2].foo|urlencode}">{$data[data2].bar}</a></td>
{/section}
</tr>
{/section}
</table>

In this why the PHP can generate one array of $data. The template can
decide whether to display it in a conventional row by row or this
column by column data. All with no extra stuff set on the PHP side.

Regards,

Abdul-Wahid
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com