This is a small patch to make the already very powerful theme system even more accessible and functional.
theme_table: This patch will allow you to tag cells as headers to make the already available functionally of _theme_table_cell accessible to you. By adding a header key with either one of the values 1, true, or `th` theme_table can now generate headings for you on the side of the table in a row in the centre anywhere you want them.
This is already implemented but duplicated in the latest patch for the modules administration page which makes the modules screen look so much neater with all the packages in one table and all the rows lined up. Each package heading can be table headings and even without style sheets are already styled appropriately.
ex:
$cells[] = array('data' => 'Cell 1', 'header' => 1);
$cells[] = array('data' => 'Cell 2', 'header' => true);
$cells[] = array('data' => 'Cell 3', 'header' => 'th');
$rows[] = array(
'data' => $cells,
'style' => 'font-weight : bold;'
);
return theme('table',array(),$rows);
theme_links: As a newcomer I found using this function very frustrating due to its complexity and lack of documentation which is a pity because this is a very powerful piece of code. Not only will it generate you a list of links but it will also surround some text with span tags and you can add custom attributes to these albeit by using three nested arrays. To simplify this process and be more consistent with other elements for example row, header or cell you can now also add attributes right next to title and href or use the old way of combining them in an attribute array.
ex:
$output = theme('links', array(array(
'title' => t('span'),
'href' => 'testthemepatch/test',
'class' => 'modules-heading',
'style' => 'font-weight : bold;'
)
));
return $output;
In stead of:
$output = theme('links', array(array(
'title' => t('span'),
'href' => 'testthemepatch/test',
'attributes' => array(
'class' => 'modules-heading',
'style' => 'font-weight : bold;')
)
));
return $output;
Your comments and suggestions are welcomed and appreciated.
Comment | File | Size | Author |
---|---|---|---|
#6 | theme.inc_table_header.patch | 685 bytes | nickl |
#4 | theme.inc_3_0.patch | 1.3 KB | nickl |
#3 | testthemepatch_2.module.tar.gz | 1.53 KB | nickl |
#2 | theme.inc_2_0.patch | 1.53 KB | nickl |
#1 | testthemepatch.module.tar.gz | 1.54 KB | nickl |
Comments
Comment #1
nickl CreditAttribution: nickl commentedHere is a test case module to test past and new functionality.
Comment #2
nickl CreditAttribution: nickl commentedAfter review by Morbus we have decided to remove the multiple options and only use boolean true in aim of consistency for tagging a cell as a header.
This is the only valid option now:
Comment #3
nickl CreditAttribution: nickl commentedTest case examples updated.
Comment #4
nickl CreditAttribution: nickl commentedMore cosmetic changes and me not following standards. *sigh*
Comment #5
Morbus IffI'm all for the 'header' addition. Not so much for the theme_links change. (To repeat from IRC: "i think part of the problem is that attributes allows us not to whitelist all our known parameters. if we, for instance, add a "style" attribute to theme_links in the future, there'd be a huge problem if someone wanted to add a CSS style. since theyre'd be a namepsace clash. i think the determination has been "useful and required things are non-attributes" and "everything else is inside attributes". that way, we have a split namespace between need and want.)
So +1 to the header thing, -1 to the theme_links change. To demonstrate the header thing, you could fix up the watchdog log display (admin/log/event/1234), though you'll probably have to add a new CSS style for #watchdog th, since the th will be inherited with a bottom border which'll look retarded on that page.
Comment #6
nickl CreditAttribution: nickl commentedNew patch file for table header approved fix.
Comment #7
adrian CreditAttribution: adrian commented+1 .. this is a decent patch , and a necessary approach.
Comment #8
adrian CreditAttribution: adrian commentedready to be committed.
Comment #9
Steven CreditAttribution: Steven commentedCommitted a shorter patch to HEAD which also documents this feature in the doxygen.
Comment #10
(not verified) CreditAttribution: commented