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().
Comment | File | Size | Author |
---|---|---|---|
#1 | token_theme_table-2026011.patch | 336 bytes | quicksketch |
|
Comments
Comment #1
quicksketchIt 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.
Comment #2
Chris Matthews CreditAttribution: Chris Matthews as a volunteer commentedThe 6 year old patch to token.module applied cleanly to the latest token 7.x-1.x-dev and is a straight-forward RTBC.
Comment #4
Dave ReidCommitted to 7.x-1.x.