Problems:

  1. div#dashboard doesn't live in div#block-system-main which results in awkward markup (read WTF).
  2. Dashboard region classes don't run through drupal_region_class() which results in classes containing underscores
  3. Dashboard block classes don't run through drupal_html_class() (underscores in classes again)
  4. Any blocks that have been specifically themed loose anything custom because this module makes its own theme functions
  5. Those theme functions don't even try to be consistent with the way blocks are done, i.e. preprocessing classes, etc.

It seems that a lot (if not all) of what these theme functions are doing can be achieved with dashboard_preprocess_block? Maybe I'm wrong on that, but most of my interaction with this module so far (from a theming perspective) has not been good at all.

I'd like to know: Can anything can be done at this point to improve this?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

David_Rothstein’s picture

Status: Active » Needs work
FileSize
1.38 KB

Here's a start at addressing the underscores issue (#2 and #3), although since currently the dashboard region names are used as IDs, not classes, I did it using drupal_html_id().

The markup for the dashboard regions is indeed not consistent with the way other regions in Drupal are done - e.g., drupal_region_class() and all that - but I'm not sure what the right behavior is here. They are not "really" their own regions, but rather sort of part of the main page content... so what should their markup look like?

For #1, as mentioned on another issue this might be difficult... but from a theming perspective, what is the use case you are thinking about? The reason I'm wondering is that I'm not sure in Drupal 7 themers can ever rely on the main page content appearing within div#block-system-main. For example, if someone is using Panels to manage their page regions rather than the Block module, I wonder what the markup of a regular page will look like then?

For #4 and #5, which theme functions are you referring to? The one I see that might be relevant is http://api.drupal.org/api/function/theme_dashboard_disabled_block/7. I'm not too familiar with that but as far as I know it's only used to display disabled blocks (i.e., the dark gray ones at the top when you click "Customize dashboard"). If so, those are kind of in their own world anyway. I wonder if the problem is more that they are themed too much like regular blocks (e.g., using some of the same IDs and classes) rather than not enough? I would think that in most cases a themer would not want to touch a block in that state at all, at least not in the same way they are theming a block that is actually being displayed...

Jacine’s picture

You are awesome :D

My problem for the regions is only the underscores. I agree that they don't need to be consistent with other regions as far as their markup is concerned.

For #1, I totally expect to be able to rely on main page content appearing in #block-system-main. I am curious to know what Panels would do in this situation, but I did try Views with a page display its content does end up in #block-system-main. I expect Panels to do the same. I am also not happy about the large empty space I get in the #block-system-main on the dashboard page because I simply applied margin to the block and its content. It contains a hidden warning message for users to turn on Javascript.

As for a use case, a simple one would be applying a border #block-system-main, trying to target the main content. You'd get a small empty box, because of that hidden Javascript message, and then have to make a special case for the #dashboard. Not good.

For #4 & #5, I didn't realize that this was only being used for disabled blocks. I thought maybe there was some Javascript loading the content into the empty div when it is moved into a region, so I take that back. I agree 100% about this being themed too much like a regular block though. If all we need is a title here, why have all this crud (markup & CSS)? I would much rather see only what is needed printed out.

Even if we left the block theme functions the way they are though, there will still be underscore problems with the classes (for modules with underscores in their name).

mr.baileys’s picture

Even if we left the block theme functions the way they are though, there will still be underscore problems with the classes (for modules with underscores in their name).

As David alluded too in the other issue, there is some overlap between this issue and #936798: Dashboard uses unreliable method for identifying blocks.. That issue (tries to) explain why underscores are required in (some of) the class names. IIRC, underscores are legal characters in CSS class identifiers. Is it a coding guideline to avoid using underscores in classes?

webchick’s picture

There was a bit of a rant tonight in #drupal-contribute about dashboard module's theme functions and such. :) I'm going to attempt to summarize, just so it's captured somewhere where someone might do something about it. Thanks to Jacine for a pointer to this issue.

- There's a theme_dashboard_region(). But we already have region.tpl.php and theme hook suggestions. Why not use them?
- extract($variables) ? Ick.
- theme_dashboard_disabled_block includes a bunch of hard-coded classes. These should be using the $classes array.
- dashboard_theme() uses block module's form template instead of making one for dashboard so it can be styled separately.
- All of the theme functions in this file have similar problems, and all should be cleaned up.

cosmicdreams’s picture

I'm currently running into these issues in this module's CSS cleanup.

tim.plunkett’s picture

Status: Needs work » Needs review
FileSize
3.2 KB

Killed the needless extract() usage.

Status: Needs review » Needs work

The last submitted patch, drupal-720544-6.patch, failed testing.

tim.plunkett’s picture

Version: 7.x-dev » 8.x-dev
Status: Needs work » Needs review
Issue tags: +Needs backport to D7

Whoops, I didn't notice what version the issue was on.
I don't think the CSS is backportable, but some of this will be.

tim.plunkett’s picture

#6: drupal-720544-6.patch queued for re-testing.

webchick’s picture

Issue tags: -Needs backport to D7

Actually, I don't see anything here we could backport to D7. Go go go on cleanup for D8 though. :)

webchick’s picture

Issue tags: +Needs backport to D7

Oh, my mistake. We're just replacing extract($variables) for long-hand $variables['foo']. Hm. That's probably safe.

tim.plunkett’s picture

FileSize
2.91 KB

This is probably better than re-using variables each time. And it's follows the more common pattern I've seen.

Status: Needs review » Needs work

The last submitted patch, drupal-720544-12.patch, failed testing.

star-szr’s picture

Version: 8.x-dev » 7.x-dev

Dashboard module is no longer in core, see #950956: Remove Dashboard from core . Moving to 7.x for consideration.