Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The COLGROUP HTML tag is used in tables. This tag is used by diff.module (among others). The proposal here is to add support for this feature to theme_table() so that diff module can get rid of its reimplementation of theme_table(). I think we will find several uses for this, but for I just want the framework to support it.
Comment | File | Size | Author |
---|---|---|---|
#11 | table-colgroup-239071-11.patch | 3.14 KB | floretan |
#6 | table-colgroup-239071-6.patch | 3.12 KB | floretan |
#2 | mw.patch | 2.14 KB | moshe weitzman |
Comments
Comment #1
dvessel CreditAttribution: dvessel commented++ I'd like to see this supported. Table data can get really interesting visually with simpler class naming among other things.
Comment #2
moshe weitzman CreditAttribution: moshe weitzman commentedHere is a patch. This is straight from diff module. Thats god, because this diff code is currently in use on drupal.org and on sites everywhere.
Comment #3
floretan CreditAttribution: floretan commentedI applied the patch and I was able to affect a table with the $cols parameter, but figuring out the proper format was far from easy (even for someone who's familiar with the array structure for the $header and $rows parameters).
The documentation for the $cols parameter should be expanded and provide the same level of detail as the other two. Other than that this patch looks good to me.
Comment #4
moshe weitzman CreditAttribution: moshe weitzman commentedagreed. any chance you can write that up, flobruit? i will put it in the patch if you don't want to deal with command line.
Comment #5
Susurrus CreditAttribution: Susurrus commentedBecause of #3 and #4.
Comment #6
floretan CreditAttribution: floretan commentedThe $cols parameter is actually passing information about COLGROUP elements, so the name of the parameter should be $colgroups. Unlike headers and rows, column groups don't have cells, so that terminology in the code is not accurate.
Here's a patch with the following variable name changes:
The code logic looks good and hasn't been altered.
The patch also includes a more extensive doxygen documentation with examples. I found it difficult to be clear about the parameter definition without referring to the corresponding HTML elements, so suggestions for better alternatives are welcome.
Comment #7
floretan CreditAttribution: floretan commentedMoshe suggested outside of this issue that this colgroup functionality could be used to indicate the "active" column in sorted tables, so I took some time to investigate this feasibility. The outcome is that using colgroups to indicate the active column would come at the price of other complications:
colgroup
andcol
elements, but the background color oftr
elements takes precedence and there is no way to targettd
elements inside of a specific columns using CSS rules.th
andtr
elements, we can use tablesort_cell() to figure out if they are in the active column because we can make the assumption that the 'span' attribute is not used on sortable tables. However, this is not true forcolgroup
andcol
elements. We could figure out the active column by parsing the 'span' attributes but this is pretty messy and probably not a valuable addition to the table theme function.Comment #8
moshe weitzman CreditAttribution: moshe weitzman commentedVery nice docs, flobruit. Thanks.
I tested and this didn't break any tables. I think thats sufficient for now.
Comment #9
drewish CreditAttribution: drewish commentedsubscribing
Comment #10
Dries CreditAttribution: Dries commented* The PHPdoc is wrapped inconsistently. Better to wrap it more or less at the same width/length. Otherwise looks good.
* Tests wouldn't hurt, although it might be difficult to test.
* Can we use colgroups anywhere in core?
Comment #11
floretan CreditAttribution: floretan commented* Re-rolled patch and adjusted PHPdoc wrapping.
* Tests would indeed be nice, but how do we test theme functions?
* As mentioned in #7, colgroups cannot be used for the active column of sorted tables. I looked for other places in core where this could be used but didn't find any.
Comment #12
moshe weitzman CreditAttribution: moshe weitzman commentedThanks flobruit. I think we your addressed Dries' questions, and this is RTBC. It applies correctly still.
Comment #13
Dries CreditAttribution: Dries commentedThanks for fixing the comments, and the clarifications. I've committed this to CVS HEAD. Thanks.
Comment #14
Anonymous (not verified) CreditAttribution: Anonymous commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #15
MurzAt May 23, 2008 I see message "committed this to CVS HEAD", but I didn't see this in Drupal 6.14.
And no changes in api: http://api.drupal.org/api/function/theme_table/6
In which HEAD does this patch committed?
Comment #16
moshe weitzman CreditAttribution: moshe weitzman commentedYOu are looking at Drupal6 pages. This is part of Drupal7. See http://api.drupal.org/api/function/theme_table/7
Comment #17
MurzOk, in 7.x-dev I have found it. And last patch applied succesfully on Drupal 6.14.