Skip to content

dokuwiki api tables

LarsGit223 edited this page Jun 30, 2016 · 10 revisions

This section describes creation of tables.

Simple table functions

These are the basic table functions with a predefined style. These are also called for basic DokuWiki rendering and therefore the function declarations need to match the class Doku_Renderer.

table_open($maxcols = NULL, $numrows = NULL, $pos = NULL)

The function opens a table. $maxcols specifies the number of columns. Parameters $numrows and $pos are unused.

table_close($pos = NULL)

The function closes a table. Parameter $pos is unused.


tablerow_open()

The function opens a new table row.

tablerow_close()

The function closes a table row.


tableheader_open($colspan = 1, $align = "left", $rowspan = 1)

The function opens a new table header cell. The cell will span $colspan columns and $rowspan rows. The content in the cell will be aligned according to $align ('left', 'center' or 'right').

tableheader_close()

The function closes a table header cell.


tablecell_open($colspan = 1, $align = "left", $rowspan = 1)

The function opens a new table cell. The cell will span $colspan columns and $rowspan rows. The content in the cell will be aligned according to $align ('left', 'center' or 'right').

tablecell_close()

The function closes a table header cell.


Code examples for simple table functions

Simple table with 2 columns

The following code:

    $renderer->table_open(2);

    $renderer->tablerow_open(1);
    $renderer->tablecell_open();
    $renderer->cdata('Cell 1/1');
    $renderer->tablecell_close();
    $renderer->tablecell_open();
    $renderer->cdata('Cell 1/2');
    $renderer->tablecell_close();
    $renderer->tablerow_close(1);

    $renderer->tablerow_open(1);
    $renderer->tablecell_open();
    $renderer->cdata('Cell 2/1');
    $renderer->tablecell_close();
    $renderer->tablecell_open();
    $renderer->cdata('Cell 2/2');
    $renderer->tablecell_close();
    $renderer->tablerow_close(1);

    $renderer->table_close(2);

generates a tables with 2 columns and 2 rows.

Clone this wiki locally