Skip to main content
knackforge blog knowledge base

Drupal : Disable sticky header behavior of theme_table()

Lately I have been working on a potential Drupal 6 project that needs displaying information in a formatted table structure. Needless to say I have been using a lot of pager_query() and theme_table(). Yes, I do understand the benefits of hook_views_data() but this is a different case.

One thing I found to be annoying about theme_table() is it's default behavior of adding sticky table header and not having an argument that can be passed to disable it when needed as introduced in D7

The snippet that sets sticky header is as below,

function theme_table($header, $rows, $attributes = array(), $caption = NULL) {
// Add sticky headers, if applicable.
if (count($header)) {
// Add 'sticky-enabled' class to the table to identify it for JS.
    // This is needed to target tables constructed by this function.
$attributes['class'] = empty($attributes['class']) ? 'sticky-enabled' : ($attributes['class'] . ' sticky-enabled');


I did try the old phptemplate_preprocess_page() trick that appears first in Google search results. For some reason it didn't work for me, besides I'm not happy adding too much of code into the expensive function.

Preprocess function trick code snippet from Drupal forum,

function phptemplate_preprocess_page(&$vars) {
$vars['tabs2'] = menu_secondary_local_tasks();

// Hook into color.module
if (module_exists('color')) {

// remove sticky table headers
$js = drupal_add_js();
$vars['scripts'] = drupal_get_js('header', $js);


Alternatively I tried CSS display: none trick which produced the same output as I expected with least code. All it needed is to add this one line style to custom CSS file.

table.sticky-header { display: none !important; } 

Bingo !!