News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

XHTML error

Started by gog, July 29, 2006, 05:24:57 AM

Previous topic - Next topic

gog

There is one small error, since SMF defaults to XHTML output there is a little problem with Board (category) names. On the board index, you have:

<a name="2" href="http://www.simplemachines.org/community/index.php?action=collapse;c=2;sa=expand#2">Simple Machines</a>

In XHTML you have to use id's for anchors, not "name" attributes. For compatibility reasons it would be advisable to use both id and name. The problem is that the value of "name" is an integer, and id's can't start with an integer.

The simplest way to resolve this problem is to add "id" and prefix it with, for example "a". To do this edit Sources/BoardIndex.php search for line:

$context['categories'][$row_board['ID_CAT']]['link'] = '<a name="' . $row_board['ID_CAT'] . '" href="' . (isset($row_board['canCollapse']) ? $context['categories'][$row_board['ID_CAT']]['collapse_href'] : $context['categories'][$row_board['ID_CAT']]['href']) . '">' . $row_board['catName'] . '</a>';

and replace it with:

$context['categories'][$row_board['ID_CAT']]['link'] = '<a name="a' . $row_board['ID_CAT'] . '" id="a' . $row_board['ID_CAT'] . '" href="' . (isset($row_board['canCollapse']) ? $context['categories'][$row_board['ID_CAT']]['collapse_href'] : $context['categories'][$row_board['ID_CAT']]['href']) . '">' . $row_board['catName'] . '</a>';

Can you tell me if you are going to include this "fix" in the next release? I wouldn't like to change it myself and having to change it again later when new version arrives, I don't like to change my URI's to often :)

gog

Can I hear something from the developers please!   ;)

gog

OK, I guess that's a no :) Nevermind, I've made some changes as stated in the first post, and there were some other issues as well.

In Javascript one should escape "</" that is used in HTML often. for example document.write("</P>"); should really be document.write("<\/P>");.

If you are a freak like me :) you can do the following. In your themes folder (if you don't find this files in your theme folder look into the default one and copy it):

Disclaimer: I run a CVS version, your mileage may vary...

edit Display.template.php
- line 554 fix </div>, </textarea>, </div> into <\/div>, <\/textarea>, <\/div>, the line starts with var smf_template_body_edit = \'<div

-line 561:
var smf_template_subject_normal = \'<a href="', $scripturl, '?topic=', $context['current_topic'], '.msg668875#msg668875">%subject%</a>\';
should be:
var smf_template_subject_normal = \'<a href="', $scripturl, '?topic=', $context['current_topic'], '.msg668875#msg668875">%subject%<\/a>\';

Edit MessageIndex.template.php
- line 431 from:

setInnerHTML(cur_subject_div, \'<a href="', $scripturl, '?topic=\' + cur_topic_id + \'.0">\' + subject + \'</a>\');

to

setInnerHTML(cur_subject_div, \'<a href="', $scripturl, '?topic=\' + cur_topic_id + \'.0">\' + subject + \'<\/a>\');

That's I believe all folks. Install HTML validator extension and feel free to browse my forum at www.webote.com/forum/ (croatian only :) )

Advertisement: