Start page / Template development / Template syntax / Functions / in the header / Table

Table

Contents

The content of a DOMTABLE input component can be output with the format templates with the abbreviations table, tr and td (see pages Default format templates,Output et al. within Chapter Format templates). Use of the format templates is in the order table format template once for the table, tr for each row and td for each cell.

A table can therefore be output with little effort using the $CMS_VALUE(...)$ instruction:

$CMS_VALUE(IDENTIFIER)$

Output with the help of format templates is useful if all tables in a project are to have the same structure and the same appearance.

However, if tables with different or complex appearance are to be generated this can be realised with the Table function.

Important If no definition is specified for the table (e. g. missing HEADERSPEC definition), a row (e. g. missing ROW definition) or a cell (e. g. missing COL definition), the default format templates are used for the table. In this case, the format template with the abbreviation table will be used for the table, the format template with the abbreviation tr for rows and the format template with the abbreviation td for cells.
Important Another option for using tables in FirstSpirit are the so-called Inline tables (CMS_INPUT_DOM with parameter table="yes").

Syntax of the Table function

The basic structure of the Table function is as follows:

<CMS_FUNCTION name="Table" resultname="IDENTIFIER">
<CMS_VALUE_PARAM name="tableData" value="IDENTIFIER" />
<CMS_NODE_PARAM name="tableFormat">
<HEADERSPEC><![CDATA[...$CMS_VALUE(#content)$...]]></HEADERSPEC>
<ROWSPEC name="IDENTIFIER"><![CDATA[...$CMS_VALUE(#content)$...]]></ROWSPEC>
<ROW number="INTEGER"><![CDATA[...$CMS_VALUE(#content)$...]]></ROW>
<ROW number="INTEGER-INTEGER"><![CDATA[...$CMS_VALUE(#content)$...]]></ROW>
<ROW number="INTEGER-%n"><![CDATA[...$CMS_VALUE(#content)$...]]></ROW>
<ROW number="ODD"><![CDATA[...$CMS_VALUE(#content)$...]]></ROW>
<ROW number="EVEN"><![CDATA[...$CMS_VALUE(#content)$...]]></ROW>
<ROW number="ALL"><![CDATA[...$CMS_VALUE(#content)$...]]></ROW>
<ROW number="ALL" spec="IDENTIFIER" />
<CELLSPEC name="IDENTIFIER"><![CDATA[...$CMS_VALUE(#content)$...]]></CELLSPEC>
<CELL row="INTEGER" col="INTEGER"><![CDATA[...$CMS_VALUE(#content)$...]]></CELL>
<CELL row="INTEGER-INTEGER" col="INTEGER-INTEGER"><![CDATA[...$CMS_VALUE(#content)$...]]></CELL>
<CELL row="INTEGER-%n" col="INTEGER-%n"><![CDATA[...$CMS_VALUE(#content)$...]]></CELL>
<CELL row="ODD" col="ODD"><![CDATA[...$CMS_VALUE(#content)$...]]></CELL>
<CELL row="EVEN" col="EVEN"><![CDATA[...$CMS_VALUE(#content)$...]]></CELL>
<CELL row="ALL" col="ALL"><![CDATA[...$CMS_VALUE(#content)$...]]></CELL>
<CELL row="ALL" col="ALL" filltype="FILLED"><![CDATA[...$CMS_VALUE(#content)$...]]></CELL>
<CELL row="ALL" col="ALL" filltype="EMPTY"><![CDATA[...$CMS_VALUE(#content)$...]]></CELL>
<CELL row="ALL" col="ALL" spec="IDENTIFIER" />
</CMS_NODE_PARAM>
</CMS_FUNCTION>
Important The parameters tableData and tableFormat are mandatory parameters.

System objects within the Table function

System objects are available within the tags in the tableFormat parameter. The available system objects are given in the following table:

 

#table

#cell

#content

HEADERSPEC

available

not available

available

ROWSPEC

available

not available

available

ROW

available

not available

available

CELLSPEC

available

available

available

CELL

available

available

available

    

Parameters of the table function

The Table function has the following parameters:

The tableFormat parameter is also divided into tags:

tableData parameter

The mandatory parameter tableData is used to make the data entered in a DOMTABLE input component available to the Table function.

The identifier of the input component must be given as the value for the parameter:

<CMS_INPUT_DOMTABLE name="st_table">
...
</CMS_INPUT_DOMTABLE>

<CMS_FUNCTION name="Table" resultname="fr_st_table">
<CMS_VALUE_PARAM name="tableData" value="st_table" />
...
</CMS_FUNCTION>

tableFormat parameter

The formats to be applied to the table are specified in the mandatory parameter tableFormat.

The following tags are available for describing the formatting:

Tag CELL

The CELL tag is used to specify the output definition of a cell.

coll / row

The mandatory attributes col and row are used to specify the rows and columns which the definition is to apply.

Possible values for the attributes col and row are:

  • ALL
    applies to all rows/columns
  • EVEN
    applies to all even rows/columns
  • LAST (last element)
    applies to the last row/column;
    Synonym for specification of the wildcard %n as constant
  • ODD
    applies to all odd rows/columns
  • INTEGER (constant)
    applies to the given row/column;
    whereby the wildcard %n can be used for the last row/column (synonym for LAST).
  • INTEGER-INTEGER (range)
    applies to the given range of rows/columns;
    whereby the wildcard %n can be used for the last row/column.

The given parameters are evaluated from special (INTEGER) to general (ALL) values. The first applicable definition is output. It must be noted that the value LAST and the specification of the wildcard %n for INTEGER are treated equally.

Example:

<CMS_FUNCTION name="Table" resultname="fr_st_table">
<CMS_VALUE_PARAM name="tableData" value="st_table" />
<CMS_NODE_PARAM name="tableFormat">
...
<CELL col="ALL" row="ALL"><![CDATA[<td colspan="$CMS_VALUE(#cell.colspan)$" rowspan="$CMS_VALUE(#cell.rowspan)$">$CMS_VALUE(#content)$</td>]]></CELL>
</CMS_NODE_PARAM>
</CMS_FUNCTION>

The CELL definition given in the example is applied to all columns and rows.

In addition to the mandatory attributes the two optional attributes filltype and spec can be used.

filltype

By specifying the filltype attribute the output takes into account whether the content of a cell is filled or not filled.

To apply a definition to filled cells only the value FILLED must be given. For empty cells, EMPTY must be given.

Example:

<CMS_FUNCTION name="Table" resultname="fr_st_table">
<CMS_VALUE_PARAM name="tableData" value="st_table" />
<CMS_NODE_PARAM name="tableFormat">
<HEADERSPEC><![CDATA[<table>$CMS_VALUE(#content)$</table>]]></HEADERSPEC>
<ROW number="ALL"><![CDATA[<tr>$CMS_VALUE(#content)$</tr>]]></ROW>
<CELL col="ALL" row="ALL" filltype="FILLED"><![CDATA[<td colspan="$CMS_VALUE(#cell.colspan)$" rowspan="$CMS_VALUE(#cell.rowspan)$">FILLED</td>]]></CELL>
<CELL col="ALL" row="ALL" filltype="EMPTY"><![CDATA[<td colspan="$CMS_VALUE(#cell.colspan)$" rowspan="$CMS_VALUE(#cell.rowspan)$">EMPTY</td>]]></CELL>
</CMS_NODE_PARAM>
</CMS_FUNCTION>

With the example the output for a cell with content is: FILLED and the output for a cell without content is: EMPTY.

spec

The optional attribute spec applies a CELLSPEC definition to the given cell. In order for the definition to be applied the identifiers must match:

<CMS_FUNCTION name="Table" resultname="fr_st_table">
<CMS_VALUE_PARAM name="tableData" value="st_table" />
<CMS_NODE_PARAM name="tableFormat">
...
<CELLSPEC name="cell"><![CDATA[<td colspan="$CMS_VALUE(#cell.colspan)$" rowspan="$CMS_VALUE(#cell.rowspan)$">$CMS_VALUE(#content)$</td>]]></CELLSPEC>
<CELL col="ALL" row="ALL" spec="cell" />
</CMS_NODE_PARAM>
</CMS_FUNCTION>
Important When using the attribute spec, the CELL tag may not contain any CDATA blocks!

Tag CELLSPEC

The CELLSPEC tag is a known cell template which can be used in a CELL tag. To this end the identifier specified in the name attribute in the CELL tag is used:

<CMS_FUNCTION name="Table" resultname="fr_st_table">
<CMS_VALUE_PARAM name="tableData" value="st_table" />
<CMS_NODE_PARAM name="tableFormat">
...
<CELLSPEC name="cell"><![CDATA[<td colspan="$CMS_VALUE(#cell.colspan)$" rowspan="$CMS_VALUE(#cell.rowspan)$">$CMS_VALUE(#content)$</td>]]></CELLSPEC>
<CELL col="ALL" row="ALL" spec="cell" />
</CMS_NODE_PARAM>
</CMS_FUNCTION>

Tag HEADERSPEC

The HEADERSPEC tag is the basic template for a table as it contains the basic structure of the table. If a table is generated HEADERSPEC is evaluated once and the most applicable ROW definition is evaluated for each row and the most applicable CELL definition for each cell:

The definition for a HTML table usually contains the opening and closing table tag, as well as $CMS_VALUE(#content)$ for the content of the table:

<CMS_FUNCTION name="Table" resultname="fr_st_table">
<CMS_VALUE_PARAM name="tableData" value="st_able" />
<CMS_NODE_PARAM name="tableFormat">
<HEADERSPEC><![CDATA[<table>$CMS_VALUE(#content)$</table>]]></HEADERSPEC>
...
</CMS_NODE_PARAM>
</CMS_FUNCTION>

Tag ROW

The ROW tag is used to specify the output of a row.

number

The mandatory attribute number is used to specify the rows to which the definition is to apply.

Possible values for the attribute number are:

  • ALL
    applies to all rows/columns
  • EVEN
    applies to all even rows/columns
  • LAST (last element)
    applies to the last row/column;
    Synonym for specification of the wildcard %n as constant
  • ODD
    applies to all odd rows/columns
  • INTEGER (constant)
    applies to the given row/column;
    whereby the wildcard %n can be used for the last row/column (synonym for LAST).
  • INTEGER-INTEGER (range)
    applies to the given range of rows/columns;
    whereby the wildcard %n can be used for the last row/column.

The given parameters are evaluated from special (INTEGER) to general (ALL) values. The first applicable definition is output. It must be noted that the value LAST and the specification of the wildcard %n for INTEGER are treated equally.

Example:

<CMS_FUNCTION name="Table" resultname="fr_st_table">
<CMS_VALUE_PARAM name="tableData" value="st_table" />
<CMS_NODE_PARAM name="tableFormat">
...
<ROW number="ALL"><![CDATA[<tr>$CMS_VALUE(#content)$</tr>]]></ROW>
</CMS_NODE_PARAM>
</CMS_FUNCTION>

The ROW definition given in the example is applied to all rows.

spec

The optional attribute spec applies a ROWSPEC definition to the given cell. In order for the definition to be applied the identifiers must match:

<CMS_FUNCTION name="Table" resultname="fr_st_table">
<CMS_VALUE_PARAM name="tableData" value="st_table" />
<CMS_NODE_PARAM name="tableFormat">
...
<ROWSPEC name="row"><![CDATA[<tr>$CMS_VALUE(#content)$</tr>]]></ROWSPEC>
<ROW number="ALL" spec="row" />
</CMS_NODE_PARAM>
</CMS_FUNCTION>
Important When using the attribute spec, the ROW tag may not contain any CDATA blocks!

Tag ROWSPEC

The ROWSPEC tag is a known row template which can be used in a ROW tag. To this end the identifier specified in the name attribute in the ROW tag is used:

<CMS_FUNCTION name="Table" resultname="fr_st_table">
<CMS_VALUE_PARAM name="tableData" value="st_table" />
<CMS_NODE_PARAM name="tableFormat">
...
<ROWSPEC name="row"><![CDATA[<tr>$CMS_VALUE(#content)$</tr>]]></ROWSPEC>
<ROW number="ALL" spec="row" />
</CMS_NODE_PARAM>
</CMS_FUNCTION>

© 2005 - 2024 Crownpeak Technology GmbH | All rights reserved. | FirstSpirit 2024.5 | Data privacy