Re: [PHP Template] Another batch of ideas

[email protected] (Monte Ohrt) Fri, 18 Feb 2000 13:41:21 -0600
Newsgroups php.template
Organization ispi
Message-ID <[email protected]>
One more idea: what if the designer would like to color every group of
three rows instead of every other row?

#GROUPBY		int,     number of the current GROUPBY block


For the first 3 rows, #GROUPBY equals 1. For rows 4-6, #GROUPBY equals
2, and so on. #EVEN and #ODD will correspond to #GROUPBY blocks if the
section attribute "groupby" is specified.

an example:

{:section myrows groupby=3}

{:if #EVEN}
	<!-- #EVEN is set for rows 4-6,10-12,16-18, ... -->
	do even stuff
{:else}
	<!-- #ODD is set for rows 1-3,7-9,13-15, ... -->
	do odd stuff
{:/if}

{:/section}

Monte Ohrt wrote:
> I really like that last idea. But instead of __FIRST__ we should use
> another prefix convention, like #VARNAME for variables internal to the
> template.
> So $varname for environment variables, %varname for config file
> variables
> and #varname for internal template variables.
> 
> Some variable ideas for sections:
> 
> #FIRST          boolean, true if in the first section loop
> #INNER          boolean, true if after #FIRST
> #LAST           boolean, true if in the last section loop
> #PREV           int,     value of previous loop row
> #LOOP           int,     value of current loop row
> #NEXT           int,     value of next loop row
> #EVEN           boolean, true if current #LOOP value is even
> #ODD            boolean, true if current #LOOP value is odd
> #TOTAL          int,     value of total number of rows
> 
> Also, we may want to define variables within sections, in
> the case of nested sections with {#sectionname:varname}
> By default, the current section will be assumed.
> 
> So an example, we want to color every other row different,
> and output the total at the bottom:
> 
> <TABLE>
> {:section myrows}
> 
> <TR>
>       <TD bgcolor={:if #EVEN}#ff0000{:else}#00eeff{:/if}>
>          table cell data
>       </TD>
> </TR>
> 
> {:/section myrows}
> 
> There were {#myrows:TOTAL} rows of data.
> 
> </TABLE>