Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 3 Articles
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
[How-to] Make Your vB Template XHTML Validate Correctly
Analogpoint's Avatar
Analogpoint
Join Date: Feb 2007
Posts: 656

 

Show Printable Version Email this Page Subscription
Analogpoint Analogpoint is offline 09-12-2007, 10:00 PM

Have you tried validating your vBulletin-powered site with the W3C validator? 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.

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:
Code:
<html
Replace with text:
Code:
<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.

Code:
<!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

Code:
<!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!
Reply With Quote
  #2  
Old 10-21-2007, 03:17 PM
foxfirediego foxfirediego is offline
 
Join Date: Aug 2005
Location: Brazil
Posts: 63
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thanks dood!
Reply With Quote
  #3  
Old 10-26-2007, 11:47 PM
Audentio's Avatar
Audentio Audentio is offline
 
Join Date: Mar 2007
Posts: 300
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Awesome, cheers!
Reply With Quote
  #4  
Old 11-14-2007, 04:47 AM
Animparadise's Avatar
Animparadise Animparadise is offline
 
Join Date: Sep 2007
Posts: 46
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

realy awesome
Reply With Quote
  #5  
Old 12-19-2007, 10:30 AM
Triky's Avatar
Triky Triky is offline
 
Join Date: Mar 2007
Location: [Italy]
Posts: 728
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Analogpoint View Post
You can check this by validating the vB forums.
With the new vB release, it should be corrected. If you check now that link, it say is Valid XHTML 1.0 Transitional.
Reply With Quote
  #6  
Old 12-19-2007, 11:11 AM
Magnumutz's Avatar
Magnumutz Magnumutz is offline
 
Join Date: Feb 2006
Location: Romania
Posts: 731
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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".
Reply With Quote
  #7  
Old 12-19-2007, 12:25 PM
Triky's Avatar
Triky Triky is offline
 
Join Date: Mar 2007
Location: [Italy]
Posts: 728
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

LOL
Reply With Quote
  #8  
Old 12-21-2007, 04:37 PM
semauae's Avatar
semauae semauae is offline
 
Join Date: Sep 2006
Location: UaE
Posts: 44
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have 2175 errors

how can I fix it ?

http://validator.w3.org/check?uri=ht...Inline&group=0
Reply With Quote
  #9  
Old 02-18-2008, 11:21 AM
Peter85 Peter85 is offline
 
Join Date: Sep 2007
Posts: 24
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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:
Code:
		$stylevar['textdirection'] = 'ltr';
Replace that with
Code:
		$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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:27 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04640 seconds
  • Memory Usage 2,277KB
  • Queries Executed 24 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (6)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (8)postbit
  • (9)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete