Nearsoft, Inc.
home » blog » Joomla as Valid XHTML 1.0



  • Forgot your password?
  • Forgot your username?
Nearsoft, Inc.

Home

  • Back to Nearsoft home

Blog Authors

  • Jorge Pablos (3)
  • Matt Perez (58)
  • Victor Velasquez (11)
  • Julio Gonzalez (10)
  • German Rodriguez (1)
  • Bobby (1)
  • Renato Fontes (2)
  • Manuel Monteverde (1)
  • Hugo Blanco (1)

Blog Categories

  • Events (1)
  • Global Affairs (2)
  • Management (18)
  • Miscellaneous (38)
  • Mobile Development (2)
  • Outsourcing (4)
  • Presentations (10)
  • Software Development (11)
  • SuperHappyDevHouse (0)

Blog Archive

  • August 2010 (3)
  • July 2010 (1)
  • June 2010 (3)
  • May 2010 (5)
  • April 2010 (3)
  • March 2010 (6)
  • February 2010 (7)
  • January 2010 (3)
  • December 2009 (1)
  • October 2009 (5)
  • September 2009 (4)
  • August 2009 (8)
  • July 2009 (8)
  • June 2009 (4)
  • May 2009 (3)
  • April 2009 (5)
  • March 2009 (8)
  • February 2009 (1)
  • January 2009 (1)
  • December 2008 (4)
  • May 2008 (1)
  • December 2007 (1)
  • January 2007 (1)

Site Menu

» home
» about us
» contact us
» blog
» site map
» faq
» other resources
» outsourcing risks
» which shore?
» case study
» managing risks
» tce
» tce scenario
» success stories
» the nearsoft (quick) intro
» nearshoring... the movie
» join us!

Follow Us!

Facebook This blog in Facebook
Twitter Twitter @nearsoft

Links

  • Blog Directory
  • Add to Technorati Favorites
Great Place to Work
WorldBlue - Most Democratic Workplaces

Closer is Better >> Nearsoft Blog

  • Blog Home
  • Tags
  • Search
  • Feed
Jorge Pablos

Joomla as Valid XHTML 1.0

Posted by Jorge Pablos on 08/14/2009 in validate XHTML , Joomla Plug-ins
/blog/joomla-as-valid-xhtml-10.html
Permalink Print PDF

When it comes to Web standards, I like to consider myself a fan and follower, although not in an obsessive kind of way.  I think that it’s also important (usually more important) to get the necessary features in the product.

To validate or not to validate, that is the question
- Me

The line for me is exactly there, I always try to deliver the best I can.  For a website, for example, standards compliance is important but meeting users’ needs is more important.

Let’s take Joomla! as an example.  This open source CMS allows you to have a website up and running much faster than if you were developing it from scratch.  It has a powerful backend and a lot of already-tested features and extensions in place.

However, when it comes to having the site be XHTML 1.0 compliant, Joomla! fights you all the way.  You can go crazy trying to do it.  I know, I’ve tried.

Creating a valid XHTML 1.0 template is not a particularly difficult thing to do if you pay even minimal attention to standards.  Extensions are a different ball of wax altogether.

Houston, We Have a Problem

Making sure that all the components and modules you use generate valid XHTML 1.0 code is damn near impossible.  Joomla! extensions (i.e., components, modules and plug-ins) are developed by lots of people from all over the world, some who care about Web standards (good) and some who don’t (not so good).

To correct this situation you have to have a pretty good understanding of Joomla’s architecture, dive into PHP/HTML code and modify its core files.  Ditto for the extensions.  That would be a crazy thing to do.  It invalidates one of the big benefits of working with an OSS CMS in that you are now going to be messing around with time-tested code.

This is unsustainable, not to mention impractical.  Every time you update one of your components, you will most likely have to implement your changes all over again.  Alternatively, you could keep track of all your customized files and then review each one and manually upgrade after each update.  More likely than not, once you’ve made extensive changes, you’ll be very reticent to update and would not be able to take advantage of bug fixes, new features, etc.

Creating Valid XHTML 1.0 Content

One popular component is TinyMCE, the default text editor that comes with Joomla!

This little monster has a mind on its own and will mess with everything you do.  You can turn off the “Code Cleanup on Startup” and “Code cleanup on save” parameters but to no avail.  If TinyMCE could talk, this is the conversation you’d have with it:  

YouYou: Hi Tiny, how have you been?
Joomla's TinyMCETiny MCE: Great, buddy, what can I do for you?
YouYou: Please put this <br /> tag in my article’s HTML code.
Joomla's TinyMCETiny MCE: He he he. You crazy. I’ll save space by putting the usual <br> instead
YouYou: No please, add the slash in there. It’s important so the site can be valid XHTML 1.0.
Joomla's TinyMCETiny MCE: Oh, I’m sorry, I already did it my way. BTW, what does “valid XHTML 1.0” mean?
YouYou: [Uncontrollable sobbing sounds]

Even if you could find a better HTML editor that listens to you and respects your feelings you may still end up with non-compliant code because each author can mess with the HTML code directly (and since we’re a technology company, many of our authors do).  In this case, you would have to monitor and check every single article that comes into the system to make sure it’s compliant.

ANOTHER APPROACH

At this point it is very tempting to just give up on the whole thing and let the site be non-compliant.

Even though passing the XHTML 1.0 validation is not vital for a Joomla!-based website, it has been bothering me for a while and I don’t like it.  I mean, we’re a technology company and this reflects badly on us.

So, I decided to create the CleanHTML plug-in to resolve this situation.

This plug-in runs after the final HTML has been generated by Joomla! and just before the page is sent to the visitor (onAfterRender Joomla! event).  At that point, the plug-in cleans up the code to make it compliant, regardless of what extensions and authors do (yeay!).

CleanHTML Features

CleanHTML can be configured to use the Tidy PHP extension to parse and fix your code to make it valid XHTML 1.0 or HMTL 4.01.

When Tidy is not available (i.e., most hosting providers still don’t include this extension) or if you just decide not to enable this feature, the plug-in can perform a set of manual cleanups using regular expressions such as replacing for , fix unescaped query strings, sanitize ID attributes, enclose and blocks of code in CDATA sections, etc.

Last but not least, you can add custom rules with raw PHP code that are then applied to the page, held in the $html variable.

For example, say you’ve noticed that some onclick attributes in certain pages are coded as onClick (i.e., making the page XHTML 1.0 non-compliant).  In this case, you can add a PHP replacement line such as:

$html = str_replace('onclick=', onclick=', $html);

This will fix all instances of this problem in all of your frontend pages.  Cool, huh?

Final Notes

It is important to mention that executing regular expression replacements for every generated page can have an impact in website performance.  This impact is almost imperceptible for the most part unless you have lots and lots of visitors and a lousy hosting provider.  Otherwise, you won’t even notice the difference.

Given the “global community” nature of Joomla!, it’s very hard to get all the contributors lined up to generate valid XHTML 1.0 websites out of the box.  For that you would need to,

  1. Have the Joomla! Core Team signed up to generate only valid XHTML 1.0 markup.
  2. Have some sort of automated QA subsystem to qualify Joomla! extensions (i.e., sounds complicated and unreal).
  3. Replace TinyMCE with one that generates valid XHTML 1.0 code.

Of course, all of this is complicated by the fact that “compliance” is somewhat of a loose thing because THERE’S NO SAMPLE IMPLEMENTATION of these standards.

Therefore, this is the only way I can think to achieve this (for now at least).  So, there you have it.  What do you think?

CleanHTML 1.0 plug-in for Joomla 1.5

If you decide to try this plug-in, please let me know if you find any issues with it so I can fix them.  I hope you find this plug-in useful.

Download Now!


[ Back ]
Bookmark
Email this

TweetBacks (Tweet this post)

Trackback(0)

TrackBack URI for this entry

Comments (16)

Subscribe to this comment's feed This comment's feed

Show/hide comments
How do you know it's worked?
0
Probably a dumb question but nothing happened so??
Jadzia , September 16, 2009
  • report abuse
  • +0
  • vote down
  • vote up
...
Jorge Pablos
Jadzia:
I recommend you to install Firefox and it's "Html Validator" complement, you can then know for sure if your page is valid XHTML or not (small green or red icon, bottom right of the browser window).

Other option is to use the W3C Markup Validation Service (if your Website is already online):
http://validator.w3.org/

When the PHP extension "Tidy" is not enabled in your hosting, the plugin can perform some "manual" cleanups, this may not be enough for you Website to validate but it will take you very close.

Using the tools I mentioned above you can identify the rest of the markup problems that are preventing your page from passing XHTML validation then you can clean them up from the CleanHTML plugin parameters using regular expressions and PHP string replacements.

I hope this helps, cheers!

Jorge Pablos , September 18, 2009
  • report abuse
  • +1
  • vote down
  • vote up
Sounds good. A few questions...
0
Thanks Jorge,

I'm a newbie to Joomla!, and I've been concerned about invalid code. I hope this will help. A few questions:

When I install the plug-in with Joomla! 1.5.15, the "version" is listed as 1.0. Is this the version of the plug-in, or the Joomla! version it's compatible with?

I like the ability to add custom search strings. Where do I add/edit that code?
Brian , December 10, 2009 | url
  • report abuse
  • +0
  • vote down
  • vote up
W3c Validation
0
Nice information, I really appreciate the way you presented.Thanks for sharing..

w3cvalidation , April 15, 2010 | url
  • report abuse
  • +0
  • vote down
  • vote up
Services | W3C Validation | SEO & Google AdWords | Copywriting | Static HTML Website Designing | SEO Packages
0
Nice information, I really appreciate the way you presented.Thanks for sharing..

w3cvalidation , April 30, 2010 | url
  • report abuse
  • +0
  • vote down
  • vote up
great article
0
Jorge, your article addresses the exact problem i'm having with one project. And i don't care to TinyMCE either. I wish there's a better editor out there. I will give it a try with your extension. This will save a lot of headache for me. Thank you very much. STV
Steven T. , May 10, 2010 | url
  • report abuse
  • +0
  • vote down
  • vote up
Thankz
0
Thanks for updating us with the nice information.
Joomla Expert , June 04, 2010 | url
  • report abuse
  • +0
  • vote down
  • vote up
great plugin
0
i've been headache validation but when i installed this plugin, wow all passed...
thanks for this great plugin :)
adhi , June 07, 2010 | url
  • report abuse
  • +0
  • vote down
  • vote up
...
0
hi, i try used this plugin...
my hosting using php5 and the extention tidy.so..
when i check to validator is passed,amazing.. but the problem is some of my link curl didnt work readed by default and the image's missing... which part i have to fixed?

thanks
ponimerah , June 11, 2010
  • report abuse
  • +0
  • vote down
  • vote up
livefaq
0
damn if you put that in the 1st minute instead of the 26th minute I could have skipped the rest of the tutorial. Still, nice work, sincerely, it's just that it wasn't clear this was not suitable for production... SEO Company
SEO Company , July 02, 2010 | url
  • report abuse
  • +0
  • vote down
  • vote up
Cheap Domains
0
Hello

Wow..... Great tips. Thanks for sharing these tips. These tips are really very useful. I appreciate your post. You really doing great job. 
Cheap Domains , July 11, 2010 | url
  • report abuse
  • +0
  • vote down
  • vote up
Website Traffic
0
Nice information, I really appreciate the way you presented.Thanks for sharing..
W3cvalidation , July 16, 2010 | url
  • report abuse
  • +0
  • vote down
  • vote up
great!!
0
great job man, it cleans up much of my w3 error and leaving me few to manually seek and destroy to pass the validation. i got 100 error, after installed reduced to 44 thts more then 50% wow! impressive.

Except..
it tense to temper website images thus images are missing (those with error coded)
but i guess u need to re do each image and put them back on.
mayb best to install this while you developing site...
:) BRAVO!
Sam , July 22, 2010
  • report abuse
  • +0
  • vote down
  • vote up
Can you fix this plugin so it no longer breaks images?
0
Perhaps this is just a tidy feature but after installing this amazing plugin on many sites that I have it works flawlessly on all but one. There is one site that it completely tears apart my css, kills the background image and destroys the layout!

This plugin is awesome! , July 23, 2010
  • report abuse
  • +0
  • vote down
  • vote up
Free Web Space
0
Register domain names with free Homepage, email and DNS. Cheap .co.uk, .com domains with instant registration. Reliable web hosting, why pay more?
Free Web Space , July 25, 2010 | url
  • report abuse
  • +0
  • vote down
  • vote up
Apricot
0
i read your blog occasionally and i own a similar one and i was just wondering if you get a lot of spam comments? If so how do you prevent it, any plugin or anything you can advise? I get so much lately it's driving me mad so any assistance is very much appreciated.
Apricot , August 17, 2010 | url
  • report abuse
  • +0
  • vote down
  • vote up

Write comment

smaller | bigger

busy
home | about us | contact us | blog | site map || faq | other resources | outsourcing risks | which shore? || case study | managing risks | tce | tce scenario | success stories || the nearsoft (quick) intro | nearshoring... the movie | join us!
© Nearsoft, Inc.  All rights reserved.