PDA

View Full Version : [How-to] Make Your vB Template XHTML Validate Correctly


Analogpoint
13 Sep 2007, 17:31
Have you tried validating your vBulletin-powered site with the W3C validator (http://validator.w3.org)? A standard vB installation will fail the validation with one error-- it's missing the xmlns attribute for html tag at the very beginning. You can check this by validating the vB forums (http://validator.w3.org/check?uri=www.vbulletin.com%2Fforum).

The <html> tag should look like <html xmlns="http://www.w3.org/1999/xhtml">

So until vB's default templates are changed to include the xmlns info, I needed a workaround, and I didn't want to manually edti dozens of templates.

In comes a brilliant feature that is implemented in the ACP. Expand the Styles & Templates section and click on Replacement Variable Manager.

Add a new Replacement Variable for each of your parent styles.

Search for text:
<html
Replace with text:
<html xmlns="http://www.w3.org/1999/xhtml"
This will add the xmlns attribute to the <html> tag and now your pages should validate as XHTML.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html dir="ltr" lang="en">Turns into

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en">
Happy Validating! :)

foxfirediego
21 Oct 2007, 17:17
thanks dood!

Audentio
27 Oct 2007, 01:47
Awesome, cheers! ;)

Animparadise
14 Nov 2007, 06:47
realy awesome :)

Triky
19 Dec 2007, 12:30
You can check this by validating the vB forums (http://validator.w3.org/check?uri=www.vbulletin.com%2Fforum).

With the new vB release, it should be corrected. If you check now that link, it say is Valid XHTML 1.0 Transitional.

Magnumutz
19 Dec 2007, 13:11
I wanted to say the same thing about 2 hours ago Triky... but then i looked at the thread date and i said to myself: "Naaaaaaaaaaaah".

Triky
19 Dec 2007, 14:25
LOL http://www.web-city.it/forum/images/smilies/asd.gif

semauae
21 Dec 2007, 18:37
I have 2175 errors

how can I fix it ?

http://validator.w3.org/check?uri=http%3A%2F%2Fsemauae.com%2Fvb&charset=%28detect+automatically%29&doctype=Inline&group=0

Peter85
18 Feb 2008, 13:21
The fix suggested by Analogpoint has the downside of making all templates showing up as modified.

Another fix for making vBulletin 3.6.x validate is to hack the includes/functions.php file.
Line 4628 (or somewhere around there) should read:
$stylevar['textdirection'] = 'ltr';

Replace that with
$stylevar['textdirection'] = 'ltr" xmlns="http://www.w3.org/1999/xhtml';

and you will have xmlns="http://www.w3.org/1999/xhtml'; inserted in the right place in your <html>-tag.

My suggestion for a fix is much uglier but it has the benefit that it can be undone very easily and doesnt make all your templates show up as modified.

Edit:
After doing some testing I realised that that variable is also used in some of the templates. So there will still be template edits. Hopefully not as many though.