Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Re: [SMARTY] section and columns
Use one table row and move to the new column when the loop is divisible
by four, so something like (untested):

<table>
{section name=category loop=$categories}
<tr>
<td>
<a
href="{$categories[category].url}">{$categories[category].
name}</a>
{if not $smarty.section.category.last}
{if $smarty.section.category.iteration is div by
4}</td><td>{else}<br />{/if}
{/if}
</td>
</tr>
{/section}
</table>

On Tue, 2004-03-02 at 12:04, Uros Gruber wrote:
> Hello!
>
>  Let say I have some array of data
>
>  and I show it like this
>
>  <table>
> {section name=category loop=$categories}
>    <tr>
>      <td>
>    <a href="{$categories[category].url}">{$categories[ca
tegory].name}</a>
>      </td>
>   </tr>
> {/section}
> </table>
>
> Is it now possible to rewrite tpl file so I can for example make
> output in two, three, four columns. So designer can choose how much
> columns to use.
>
>
> example output
>
> cat1    cat5   cat9
> cat2    cat6   cat10
> cat3    cat7   cat11
> cat4    cat8
>
> Right now I have to use array chunk before I assign array to smarty
> and then in tpl file I have to use sub section.
>
> Is this even possible?
>
> --
> tia,
>  Uros

Report this thread to moderator Post Follow-up to this message
Old Post
Monte Ohrt
03-19-04 06:28 PM


Re: [SMARTY] section and columns
On Tue, Mar 02, 2004 at 07:45:16PM +0100, Uros Gruber wrote:
> Hello!
>
> That is some sollution, but this number 4 is how many rows per column.
> This can lead to some great number of columns. What i want i set how
> many columns. Probably sollution is simple but right now I'm blind for
> it.
>
> And also I want to solve this with table, not <br>, because i have
> some other data etc. but if is no other way I can do with <br>

{assign var=cols value=3} {* configurable *}
{math assign=rows equation="ceil(a/c)" a=$data|@count c=$cols} {* 
computed *}
<table>
{section name=tr loop=$rows}
<tr>
{section name=td start=$smarty.section.tr.index
loop=$smarty.section.tr.index+$cols*$rows step=$rows}
<td>{$data[td]|default:"&nbsp;"}</td>
{/section}
</tr>
{/section}
</table>

HTH
messju

> --
> tia,
>  Uros
>
> Tuesday, March 2, 2004, 7:19:13 PM, you wrote:
>
> MO> Use one table row and move to the new column when the loop is divisibl
e
> MO> by four, so something like (untested):
>
> MO> <table>
> MO> {section name=category loop=$categories}
> MO>    <tr>
> MO>      <td>
> MO>    <a
> MO> href="{$categories[category].url}">{$categories[cate
gory].name}</a>
> MO>      {if not $smarty.section.category.last}
> MO>         {if $smarty.section.category.iteration is div by
> MO> 4}</td><td>{else}<br />{/if}
> MO>      {/if}
> MO>      </td>
> MO>   </tr>
> MO> {/section}
> MO> </table>
>
> MO> On Tue, 2004-03-02 at 12:04, Uros Gruber wrote: 
>
> --
> Smarty General Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

Report this thread to moderator Post Follow-up to this message
Old Post
Messju Mohr
03-19-04 06:28 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PHP Smarty Templates archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 10:34 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.