The theme_tree_table() function directly passes its $variables array to the theme_table() function. This is convenient because it means that you can set various properties from the parent caller.

For example theme_token_tree() uses this functionality:

  $element += array(
    '#theme' => 'tree_table',
    '#header' => array(
      t('Name'),
      t('Token'),
      t('Description'),
    ),
    '#rows' => $rows,
    '#attributes' => array('class' => array('token-tree')),
    '#empty' => t('No tokens available'),
    '#attached' => array(
      'js' => array(drupal_get_path('module', 'token') . '/token.js'),
      'css' => array(drupal_get_path('module', 'token') . '/token.css'),
      'library' => array(array('token', 'treeTable')),
    ),
  );

On my site I have overridden theme_token_tree() to customize its markup, and I would like to make the generated tree table not use the "sticky" table header. Just like the other properties, I should be able to simply set #tree = FALSE to set the sticky option. Unfortunately because the "sticky" option is not listed in hook_theme() in token.module, the #sticky property is never passed along to the theme function. The same problem also exists for the #colgroups option which is supported by theme_table(). This patch adds both missing properties to token_theme().

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

quicksketch’s picture

Status: Active » Needs review
FileSize
336 bytes

It might also be a good idea to set "sticky" = FALSE by default, but since theme_table() sets it to TRUE currently (this was changed in D8, btw, it's now FALSE by default), this patch maintains the current behavior.

Chris Matthews’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

The 6 year old patch to token.module applied cleanly to the latest token 7.x-1.x-dev and is a straight-forward RTBC.

  • Dave Reid committed dcd9978 on 7.x-1.x authored by quicksketch
    Issue #2026011 by quicksketch: Pass colgroups and sticky properties from...
Dave Reid’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 7.x-1.x.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.