Slightly larger one here. :-) The functio theme_calendar_nav_wrapper() in calendar_api.php outputs the header row of the calendar as a row of header cells. However, it does so by passing the theme('table') function an empty body array, which results in a table that contains a tbody element that has no content. a tbody element that does not contain a th element is invalid (X)HTML.
The solution is to either switch that function to use a body row rather than a header row, or beef up theme_table() in core to skip the tbody completely if there are no rows. For now, I think the former is the better option. The following code does that (again, at work so don't have CVS):
function theme_calendar_nav_wrapper($array) {
$row = array();
foreach ($array as $element) {
$row[] = $element;
}
return theme('table', array(), array($row));
}
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | empty_tbody_4-7.patch | 2.66 KB | m1mic |
Comments
Comment #1
karens commentedThe problem here is that it will produce td elements instead of th elements which makes the css much more complicated to get working correctly. Plus as a regular table row, some themes goof it up by applying the 'odd' style to it. So it needs to be a header row. I'll have to think about another way to do this...
Comment #2
karens commentedReported again at http://drupal.org/node/141707.
Comment #3
Crell commentedIt looks like someone fixed this in Drupal 6 so that theme_table() behaves better when there are no rows defined. Not much help for 4.7 or 5, but it won't be a problem for long. :-)
Comment #4
m1mic commentedThis was originally reported as a bug in the Calendar module, but the theme_table() function was the root cause. Backporting the solution from Head. Please see Issue 171461 for more details.
Comment #7
susata commentedHas anyone come up with a solution for this issue for Drupal 5.x? If so, I would appreciate if someone could please point me in that direction. Thanks!
s.
Comment #8
francoud commentedJust had the same problem right yesterday :)
I tried apply this patch (drupal 5.6): http://drupal.org/files/issues/theme_inc_tbody.patch
Documented here: http://drupal.org/node/171461
It solved my problem :))
Comment #9
susata commentedfrancoud, Thanks for the great tip!!! The patch works wonderfully in my 5.5 installation.
s.
Comment #10
m1mic commentedI backported the patch that was used in DRUPAL-6 dev cycle to DRUPAL-5-dev. Please see http://drupal.org/node/171461#comment-732368.
Comment #11
susata commentedPlease forgive the newbie question... Will a patch written for 5-dev be appropriate for 5.5?
Thanks,
s.
Comment #12
Crell commented@susata: Possibly, since point releases only fix bugs or security holes. You want to be running 5.7, though, as there are known security holes in 5.5. The fix is upgrading to 5.7. :-)
Comment #13
susata commentedWell, I guess I'll have to stop putting off upgrading from 5.5 (I have never done an upgrade before and am terrified of things breaking).
And then I will also upgrade to your 5.7 fix.
Thank you for providing this fix and thank you for your very wise advice re upgrading.
s.
Comment #14
Crell commentedAs 4.7 is no longer supported and Drupal 6 and later already have this patch, I guess this can be marked fixed.