rpersen logo

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:

  1. Create a new plugin and name it application/xhtml+xml.
  2. Paste the plugin code into the php code area.
  3. Create a new custom content type (MODx Manager --> Tools --> Configuration --> Custom content types) with the value application/xhtml+xml.
  4. 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");
    }
}


Write a comment

Comment
feather * = compulsary fields

If you have trouble reading the code, click on the code itself to generate a new random code.
Security code:
 
beiseabeaps
Posts: 2
Comment
All ses retber ))))
Comment #2: Tue June 08 on 13:46:11
Are you a professional journalist? You write very well.
Test
Posts: 2
Comment
Subject3
Comment #1: Tue May 18 on 10:31:17
Hello


G'night

Last updated Tue June 08 on 14:25:50

About the site | Contact