- b2evolution CMS Support Forums
- b2evolution Support
- Plugins & Extensions
- Hack to override XHTML validator
1 hategun Dec 14, 2006 11:03
I love b2evolution. Really. It's awesome. However, the one thing I find consistently infuriating is the HTML validator for posts.
It's way too strict for my taste, and often throws up ridiculous errors for code that, while maybe not being 100% valid XHTML, is perfectly acceptable to me. After all, it's my site. If I want to throw in crap code, that's my prerogative.
In the various threads I've seen on the topic, the answer seems to be either A.) edit your conf/_formatting.php file to change the $use_html_checker variable ... but make sure you change it right back OR B.) Use some sort of plug-in for YouTube, Google Video, etc.
However, I don't want to have to dive into the code every time I do a post. I just want to bypass the validator when it's throwing errors on stuff that is perfectly acceptable to me, while still maintaining the strict validation for comments by outside visitors.
The solution is simple, so I figured I'd post it here in case it can help anyone else.
Two easy steps:
1.) Add radio buttons to admin form. Open /inc/VIEW/items/_item.form.php. Scroll down about 320 lines to the ADDITIONAL ACTIONS comment. Change this:
if( $Blog->get('allowtrackbacks') )
{ // --------------------------- TRACKBACK --------------------------------------
?>
<div id="itemform_trackbacks">
<label for="trackback_url"><strong><?php echo T_('Trackback URLs') ?>:</strong> <span class="notes"><?php echo T_('(Separate by space)') ?></span></label><br /><input type="text" name="trackback_url" class="large" id="trackback_url" value="<?php echo format_to_output( $post_trackbacks, 'formvalue' ); ?>" />
</div>
<?php
}
$Form->end_fieldset();
to this:
if( $Blog->get('allowtrackbacks') )
{ // --------------------------- TRACKBACK --------------------------------------
?>
<div id="itemform_trackbacks">
<label for="trackback_url"><strong><?php echo T_('Trackback URLs') ?>:</strong> <span class="notes"><?php echo T_('(Separate by space)') ?></span></label><br /><input type="text" name="trackback_url" class="large" id="trackback_url" value="<?php echo format_to_output( $post_trackbacks, 'formvalue' ); ?>" />
</div>
<?php
}
?>
<br />
<div><strong>Check HTML?</strong></div>
<div><input type="radio" name="checkHTML" value="1" checked>Yes <input type="radio" name="checkHTML" value="0">No</div>
<?php
$Form->end_fieldset();
2.) Check for radio button value. Open /conf/_formatting.php, scroll down to around line 45, and change this:
$use_html_checker = 1;
to this:
if (isset($_POST['checkHTML'])){
$use_html_checker = $_POST['checkHTML'];
} else {
$use_html_checker = 1;
}
That's it. Now, whenever the validator is giving you problems, just change the Check HTML button to No. It will bypass the validator for that post only, while leaving it intact for everything else on the site.
Hope that helps!
3 hategun Dec 16, 2006 15:35
Yeah, this would be available to everyone. I'm a one-man show, so I don't really have any need to limit it to select bloggers. But that certainly could be done pretty easily with a simple if...then statement. I'll look into it next time I dive into the code.
I haven't tried this because the checker getting upset with me doesn't bother me, but this hack looks pretty good. Correct me if I'm wrong, but any blogger would have this option available - right? If so you might want to work up a version where only certain bloggers can have the option to uncheck it. For example maybe only bloggers in a certain group or of a certain level.
No worries though. As-is this is something many people will be happy to have available, so thanks!