RE: Table creating function?
| From: | Monte Ohrt | Date: | Sat, 03 Nov 2001 17:20:32 +0000 |
| Subject: | RE: Table creating function? | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-1829@lists.php.net to get a copy of this message | ||
{* #columns# is the number of columns you want *}
<TABLE border=1>
<TR>
{section name=numloop loop=$data}
<TD>{$data[numloop]}</TD>
{* see if we should go to the next row *}
{if not (%numloop.rownum% mod #columns#)}
</TR>
{* don't start a new row on the last loop *}
{if not %numloop.last%}<TR>{/if}
{/if}
{/section}
</TR>
</TABLE>
Peter Bowyer wrote:
>
> At 10:41 AM 11/3/01 +1000, you wrote:
> >What's the problem ?
>
> Getting the designer to understand it once the logic has been applied.
>
> ><table>
> >{section name=rowloop loop=$blah}
> ><tr>
> >{section name=colloop loop=$blah1}
> ><td>{$blah2[rowloop][colloop]}</td>
> >{/section}
> ></tr>
> >{/section}
> ></table>
> >
> >It really really really depends on what you want to do
>
> Perhaps I should explain what I am trying to do. You see, I'm writing a
> photo gallery application which will be distributed once finished. All
> HTML (as far as possible) is abstracted from the PHP, which means the logic
> is mixed in the HTML using Smarty. As many of the end-users will be
> novices at PHP/Graphic designers, I am trying to make it as simple as
> possible for them. I want them to be able to change the look of the
> application easily (which means editing the templates).
>
> Most of the application is fine, it's just the part to display the image
> thumbnails in a table which is causing problems. The end-user needs to be
> able to change the look of the table (which was the downside of PEAR
> table.php) by editing the HTML, and choose how many columns it will show
> (probably in the application setup file - this could of course be done in
> the template, but Smarty doesn't seem to have an easy way of doing
> so). The thumbnails' names and other data used are stored in a database
> table, and I am using the PEAR DB abstraction layer to extract the rows,
> and then I put them into one big array and assign it to the template
> (currently).
>
> I haven't actually managed to get your one to work yet (It's the way I
> create the PHP array that's the problem). It's certainly cleaner than what
> I came up with:
> <table width=90% border=1>
> {section name=list loop=$data}
> {if %list.first% or is_int( ( %list.index% ) / $num_columns )}
> {* first record, start table row *}
> <tr>
> {/if}
> {* display our cell data *}
> <td>{$data[list].image} on {%list.iteration%}</td>
> {if %list.last% or is_int( ( %list.index_next% ) / $num_columns )}
> {* last record, close row *}
> </tr>
> {/if}
> {/section}
> </table>
>
> My fear was that it was too complicated for any HTML designer to understand.
>
> Someone must have a better solution :-)
> Peter.
>
> --
> Devon Railway Centre - a great day out!
> http://www.devonrailwaycentre.co.uk
>
> ---
> You are currently subscribed to smarty as: monte@ispi.net
> To unsubscribe send a blank email to $subst('Email.Unsub')
> Visit Smarty's homepage at
> http://www.phpinsider.com/php/code/Smarty/
--
Monte Ohrt <monte@ispi.net>
http://www.ispi.net/