Moodle – IE8 Issues empty anchors

See: http://tracker.moodle.org/browse/MDL-18232
Issue: The section links block in Moodle is broken when using IE8.  The issue is that IE8 can’t have named anchors to blank sections.

Won’t work.
<a id=”gohere”></a>
<a href=”#gohere”>Go There</a>

Will work
<a id=”gohere”>HERE</a>
<a href=”#gohere”>Go There</a>

The fix is to add something to the anchor.  The problem is that doing so this (in Moodle) then beaks the sharing cart block, which I love.  To save both:

The suggested change of these lines in format.php:

Before:
echo ‘<tr id=”section-‘.$section.'”>’;
echo ‘<td> ‘.$currenttext.'</td>’;

After:
echo ‘<tr>’;
echo ‘<td id=”section-‘.$section.'”> ‘.$currenttext.'</td>’;

Does fix the empty tag for IE8 issue.

But, it breaks the sharing cart block locations for all sections>0. To fix this, I added a NEW ID for the section links (see below).
To fix this, without breaking sharing cart:

Before in format.php:
echo ‘<tr id=”section-‘.$section.'”>’;
echo ‘<td> ‘.$currenttext.'</td>’;

After in format.php:
echo ‘<tr id=”section-‘.$section.'”>’;
echo ‘<td id=”sectionblock-‘.$section.'”> ‘.$currenttext.'</td>’;

then in blocks/section_links/block_section_links.php
change line 76 from:

$link = ‘#section-‘;
to
$link = ‘#sectionblock-‘;

In summary – DON’T touch:
echo ‘<tr id=”section-‘.$section.'”>’;
as the sharing cart block needs it

Just a change:
echo ‘<td> ‘.$currenttext.'</td>’;
to
echo ‘<td id=”sectionblock-‘.$section.'”> ‘.$currenttext.'</td>’;
adding a new ID to it (i called it sectionblock) and then edit your sectionlinks block to look for this ID.

Leave a Reply

To get your own thumbnail image, go to gravatar.com