Skip to content
elplatt edited this page Feb 20, 2013 · 4 revisions

Overview

The table system makes it easy to display data in a row/column format. Tables are defined by implementing hook_table(). Modules can modify tables by implementing hook_table_alter(). To get the data structure for $table_id call crm_get_table($table_id). To get themed html for a table, call theme('table', $table) where $table is the table id or data structure.

Defining a table

To define a table with the id "foo", define a function foo_table($opts) which returns a Table System : Data Structure.

Altering a table defined elsewhere

If you would like to modify a table defined by another module before it is rendered, you can implement hook_table_alter($table, $table_id, $opts). When any table is rendered, this function will be called, and the Table System : Data Structure and id will be passed as $table, and $table_id. You must return the altered $table.

Getting a table structure

To get the table structure for a table with id $table_id, call crm_get_table($table, $opts). You usually won't need to do this because you can use theme() in most cases.

Displaying an html table

To render a table, call theme('table', $table_id, $opts). $table_id should be a table id string, but could also be a Table System : Data Structure.