MODx application/xhtml+xml
This simple plugin makes your pages "proper" xhtml by setting the correct MIME-type for your MODX documents. I won't go into any detail here as this is an advanced topic, but a short introduction to what application/xhtml+xml is can be found over at Schillmania!. You can also do some of the "good, ol' fashioned" Googling if you want to learn more.
Comaptible with MODx versions: All.
Please note that this plugin is a modified version of Dr. Scotty Delicious & Michal Charemza plugin. Big thanks to you guys.
Installation
The installation procedure is as easy as performing the following four steps:
- Create a new plugin and name it application/xhtml+xml.
- Paste the plugin code into the php code area.
- Create a new custom content type (MODx Manager --> Tools --> Configuration --> Custom content types) with the value application/xhtml+xml.
- On the System Events tab for the plugin, check OnWebPagePrerender.
You're plugin is now installed and ready to be used.
How to use
To activate the plugin for your xhtml pages, go to Page Settings --> Content Type and choose application/xhtml+xml.
That's it, your page should now be true xhtml (assuming you have already validated it). In Firefox this can easily be checked by looking at the page properties. If you need help or have any questions, please leave a comment.
The plugin code
header("Vary: Accept");
if($modx->documentObject['contentType'] == "application/xhtml+xml") {
if(stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml") || stristr($_SERVER["HTTP_USER_AGENT"],"W3C_Validator")) {
header("Content-Type: application/xhtml+xml; charset=utf-8");
}
else {
header("Content-Type: text/html; charset=utf-8");
}
}
Last updated Tue June 08 on 14:25:50




Posts: 2
Comment #2: Tue June 08 on 13:46:11