6.20. table_organize

Takes an unorganized set of table cells and organizes them into rows based on the number of columns.

6.20.1. Summary

    [table-organize cols* other_named_attributes]
             [loop ....] <td> [loop-tags] </td> [/loop]

    [table-organize cols=n* other_named_attributes]
             [loop ....] <td> [loop-tags] </td> [/loop]

Positional parameters: The first line shows the usage with positional parameters (given in order). The second line shows usage with named parameters.

Parameters Description Default
cols Number of columns. 2
columns Alias for cols. 2
Attributes Default
caption none
columnize none
embed none
filler &nbsp;
limit none
pretty none
rows none
table none
td none
tr none
Invalidates cache No
Macro No
Has end tag [/table-organize]

Tag expansion example:

This example produces a table that (1) alternates rows with background colors "#EEEEEE" and "#FFFFFF", and (2) aligns the columns right, center, left:

            [loop list="1 2 3 1a 2a 3a 1b"] <td> [loop-code] </td> [/loop]
        <tr bgcolor="#EEEEEE">
                <td align=right>1</td>
                <td align=center>2</td>
                <td align=left>3</td>
        <tr bgcolor="#FFFFFF">
                <td align=right>1a</td>
                <td align=center>2a</td>
                <td align=left>3a</td>
        <tr bgcolor="#EEEEEE">
                <td align=right>1b</td>
                <td align=center>&nbsp;</td>
                <td align=left>&nbsp;</td>

If the attribute columnize=1 is present, the result will look like:

            <tr bgcolor="#EEEEEE">
                    <td align=right>1</td>
                    <td align=center>1a</td>
                    <td align=left>1b</td>
            <tr bgcolor="#FFFFFF">
                    <td align=right>2</td>
                    <td align=center>2a</td>
                    <td align=left>&nbsp;</td>
            <tr bgcolor="#EEEEEE">
                    <td align=right>3</td>
                    <td align=center>3a</td>
                    <td align=left>&nbsp;</td>

See the source for more ideas on how to extend this tag.

ASP-like Perl call:

    $Tag->table_organize( { cols => 3,
                            pretty => 1, }, $BODY );

or similarly with positional parameters:

    $Tag->table_organize( $cols, $attribute_hash_reference, $BODY ); See Also

pages/flypage.html, pages/quantity.html, templates/components/best_horizontal, templates/components/cart, templates/components/cross_horizontal, templates/components/random, templates/components/random_vertical, templates/components/upsell

6.20.2. Description

Takes an unorganized set of table cells and organizes them into rows based on the number of columns; it will also break them into separate tables.

If the number of cells are not on an even modulus of the number of columns, then "filler" cells are pushed on. cols (or columns)

Number of columns. This argument defaults to 2 if not present. rows

Optional number of rows. Implies "table" parameter. table

If present, will cause a surrounding <TABLE> </TABLE> pair with the attributes specified in this option. caption

Table <CAPTION> container text, if any. Can be an array. td

Attributes for table cells. Can be an array. tr

Attributes for table rows. Can be an array. columnize

Will display cells in (newspaper) column order, i.e. rotated. pretty

Adds newline and tab characters to provide some reasonable indenting. filler

Contents to place in empty cells put on as filler. Defaults to "&nbsp;". limit

Maximum number of cells to use. Truncates extra cells silently. embed

If you want to embed other tables inside, make sure they are called with lower case <td> elements, then set the embed tag and make the cells you wish to organize be <TD> elements. To switch that sense, and make the upper-case or mixed case be the ignored cells, set the embed parameter to "lc".

    [table-organize embed=lc]
                                <TD> something


    [table-organize embed=uc]
                                <td> something

The "tr", "td", and "caption" attributes can be specified with indexes; if they are, then they will alternate according to the modulus.

The "td" option array size should probably always equal the number of columns; if it is bigger, then trailing elements are ignored. If it is smaller, no attribute is used.