Semantic DIV IDs?

Semantic DIV IDs?

by Frank Ralf -
Number of replies: 5
While trying out some theming in Moodle I stumbled across the fact that the <div> tag for the Site Administration block has a class of "block_admin_tree". My first thought was, that this should be an id instead, as there usually is only one such block per site.

<div id="inst2" class="block_admin_tree sideblock">

Then I had a lock at some Drupal code:

<div id="block-event-1" class="block block-event region-even even region-count-2 count-6">

The difference is, that the name of the block ("block-event") here is used both as a class and an id, with the id being the block name augmented with a number.

I think the way Drupal does it is a more semantical approach than using the id merely to count the number of blocks on a page as Moodle does. This makes it easier for designers to identify certain blocks.

I haven't found any documentation yet how this will be dealt with in Moodle 2.0.

Frank
Average of ratings: -
In reply to Frank Ralf

Re: Semantic DIV IDs?

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
My guess is that it won't change unless someone can do the necessary research to convince us that it won't break any existing themes.

The summary of the approach I am taking for Moodle 2.0 is that I am trying to change all the inner workings of themes, without actually changing the HTML generated by the standard theme very much. That is because

a) there is a limit to how much I can think about changing at one time, and

b) I want to keep things as backwards compatible as possible.

The only significant changes I plan to make are:
1. Try to get rid of the remaining tables for layout of blocks.
1. Clean up the inclusion of CSS and JavaScript (but that does not really count as improving the semantic HTML).
In reply to Tim Hunt

Re: Semantic DIV IDs?

by Frank Ralf -
Thanks for your reply, Tim. I'd be the first to admit that you have more than enough to do with implementing your proposed Theme engine for Moodle.

However, I think these are different aspects of theming that are of equal importance but I found the discussions on

"How hard is it to theme for Moodle?"
http://moodle.org/mod/forum/discuss.php?d=116398

and

"The Future of Moodle Templates?"
http://moodle.org/mod/forum/discuss.php?d=108993

a bit biased towards the more technical aspect of whether Moodle needs a template engine or not.

IMO a template engine is something for "hard core" themers to play with, whereas a system of well-thougt-out (semantic) ids and classes (and as less as possible extra div/span tags) helps the more "casual" themer to modify themes (see "Table Layouts vs. Div Layouts: From Hell to… Hell?" http://moodle.org/mod/forum/discuss.php?d=121217).

I'd like to hear some more opinions on this topic from the theming and usability experts.

I plan to write more elaborately on this topic in my (brand new) blog (http://moodle.org/blog/index.php?userid=728638). So stay tuned wink

Cheers,
Frank

In reply to Tim Hunt

Re: Semantic DIV IDs?

by Patrick Malley -
Hey Tim,

Since the instance number currently being used by the sideblock div ID is based on the installation, the only themes that would break are those that use the id to style a specific block. Since there are no core or third-party themes that use these ids, I assume that the owner/maintainer of the installation made the CSS change to alter the look of the specific block. Therefore, changing it to Frank's more semantic code won't be much of a theming issue since that person can easily make the necessary change themself.

With that said, considering all of the other work going into 2.0, this seems low on the priority list.
In reply to Patrick Malley

Re: Semantic DIV IDs?

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
That's pretty convincing. Can you file a bug in the tracker and make sure it gets assigned to me? Thanks.