You are here

function hook_tapir_table_header_alter in Ubercart 6.2

Allows modules to alter TAPIr table headers.

This is most often done when a developer wants to add a sortable field to the table. A sortable field is one where the header can be clicked to sort the table results. This cannot be done using hook_tapir_table_alter() as once that is called the query has already executed.

The example below adds a 'designer' column to the catalog product table. The example module would also have added joins to the query using hook_db_rewrite_sql() in order for table 'td2' to be valid. The 'name' field is displayed in the table and the header has the title 'Designer'.

Also shown are changes made to the header titles for list_price and price fields.

Parameters

$header: Reference to the array header declaration (i.e $table['#header']).

$table_id: Table ID. Also the function called to build the table declaration.

See also

hook_db_rewrite_sql()

5 invocations of hook_tapir_table_header_alter()
op_admin_comments_view_table in uc_order/uc_order.order_pane.inc
Builds the order admin comments table.
op_order_comments_view_table in uc_order/uc_order.order_pane.inc
Builds the order comments table.
op_products_customer_table in uc_order/uc_order.order_pane.inc
Builds the order customer's view products table.
op_products_view_table in uc_order/uc_order.order_pane.inc
Builds the order view products table.
uc_product_table_header in uc_product/uc_product.module
Returns the table header for the product view table.

File

docs/hooks.php, line 1517
These are the hooks that are invoked by the Ubercart core.

Code

function hook_tapir_table_header_alter(&$header, $table_id) {
  if ($table_id == 'uc_product_table') {
    $header['designer'] = array(
      'weight' => 2,
      'cell' => array(
        'data' => t('Designer'),
        'field' => 'td2.name',
      ),
    );
    $header['list_price']['cell']['data'] = t('RRP');
    $header['price']['cell']['data'] = t('Sale');
    $header['add_to_cart']['cell']['data'] = '';
  }
}