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] [table-organize cols=n* other_named_attributes] [loop ....] <td> [loop-tags] </td> [/loop] [/table-organize]
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 | |
limit | none |
pretty | none |
rows | none |
table | none |
td | none |
tr | none |
Other_Characteristics | |
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:
[table-organize cols=3 pretty=1 tr.0='bgcolor="#EEEEEE"' tr.1='bgcolor="#FFFFFF"' td.0='align=right' td.1='align=center' td.2='align=left' ] [loop list="1 2 3 1a 2a 3a 1b"] <td> [loop-code] </td> [/loop] [/table-organize] --- <tr bgcolor="#EEEEEE"> <td align=right>1</td> <td align=center>2</td> <td align=left>3</td> </tr> <tr bgcolor="#FFFFFF"> <td align=right>1a</td> <td align=center>2a</td> <td align=left>3a</td> </tr> <tr bgcolor="#EEEEEE"> <td align=right>1b</td> <td align=center> </td> <td align=left> </td> </tr>
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> <tr bgcolor="#FFFFFF"> <td align=right>2</td> <td align=center>2a</td> <td align=left> </td> </tr> <tr bgcolor="#EEEEEE"> <td align=right>3</td> <td align=center>3a</td> <td align=left> </td> </tr>
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 );
6.20.1.1. 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.
6.20.2.1. cols (or columns)
Number of columns. This argument defaults to 2 if not present.
6.20.2.2. rows
Optional number of rows. Implies "table" parameter.
6.20.2.3. table
If present, will cause a surrounding <TABLE> </TABLE> pair with the attributes specified in this option.
6.20.2.4. caption
Table <CAPTION> container text, if any. Can be an array.
6.20.2.5. td
Attributes for table cells. Can be an array.
6.20.2.6. tr
Attributes for table rows. Can be an array.
6.20.2.7. columnize
Will display cells in (newspaper) column order, i.e. rotated.
6.20.2.8. pretty
Adds newline and tab characters to provide some reasonable indenting.
6.20.2.9. filler
Contents to place in empty cells put on as filler. Defaults to " ".
6.20.2.10. limit
Maximum number of cells to use. Truncates extra cells silently.
6.20.2.11. 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> <TABLE> <TR> <TD> something </TD> </TR> </TABLE> </td> [/table-organize]
or
[table-organize embed=uc] <TD> <table> <tr> <td> something </td> </tr> </table> </TD> [/table-organize]
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.