Enstricticating MT
Comments: 4
XHTML 1.0 Strict doesn’t allow the border attribute for images or the target attribute for links. MT 2.5 includes the former when uploading images and the latter when linking to either an entry author using <$MTEntryAuthorLink$> or a comment author using <$MTCommentAuthorLink$>. If you want to enstricticate MT so that you don’t get validation errors you need to edit a couple of files in your MT installation. Details below.
Deborderizing
In the directory where you installed MT you’ll find the following file: “lib/MT/App/CMS.pm”.
There are three instances of border="0" that you need to remove. You’ll probably find them on lines 1294, 1302 and 1306 (that’s where they were for me). Delete border="0", close up the extra space, and save the file (work on a copy of the original, of course).
Now uploaded images will be tagged without a border attribute. I’ve set a global value of 0 in the style sheet because I never want borders around images (if I ever do, I can set them locally with the style attribute in the img tag).
Detargetting
The file “lib/MT/Template/Context.pm” contains the code that gets used to render author tags (among many others). On or about line 704 you’ll find an instance of target="_blank" in the <$MTEntryAuthorLink$> code. You can kill it. The instance for comment author links should be on line 983 and is likewise nukeable.
Author links will no longer spawn new windows or produce non-validating pages.
•••
Posted to MetaStuff • 2002.10.18 (Fri) • 12:45
Comments
Posted by Shawn 2002.10.31, 12:39
Thanks for this, Jeremy. Just a small correction. The second path you reference should be “/lib/MT/Template/Context.pm” rather than “/lib/MT/Templates/Context.pm”. No “s” on “Template”.
Posted by jh 2002.10.31, 23:31
Aargh! Thanks, Shawn!
Posted by Jay Allen 2003.07.25, 19:21
For anyone finding this thread now, the hack to Context.pm to remove the target=”_blank” attribute from the comment author link is no longer necessary if you are running MTv2.6 or higher.
Simply use this instead:
As long as you haven’t customized your Sanitize spec and added “href target” (see here: http://www.thegirliematters.com/tips/archives/0305/mtcommentauthorlinkandsanitize_specs.php) it will supress the printing of the XHTML-unfriendly attribute.
Posted by Bryn Dyment 2004.01.27, 06:06
Just wanted to add that HTML 4.01 Strict also disallows the target attribute.
Post a comment:
Send This Story to an Enemy
• • •