|
|
||||||
|
||||||
| Index Link To US Private Messages Archive FAQ RSS | ||||||
| Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome. |
Share Thread: & Tags
|
||||
|
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
||||
|
Interesting point, so what language should we all work in as designers?
__________________
We offer a total eCommerce solution with eCommerce Web Design using Pinnacle Cart |
|
||||
|
Interesting...both of the sites in your signature are doctyped at XHTML.
Why are you recommending HTML 4.01 Strict only? Are you saying IE can't do anything with documents built around the XHTML framework?
__________________
We offer a total eCommerce solution with eCommerce Web Design using Pinnacle Cart |
|
||||
|
Quote:
Writing xhtml1.1 for any browser without sending a proper application/xhtml+xml header is just writing "tag soup" and will be treated as "Content-type: text/html" so you need to use some server side programming to determine what the browser supports and send it a header it supports. If you send the following xml prolog and dtd Code:
<?xml version="1.0" encoding="iso-8859-1" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> The problem with internet explorer is when you write xhtml1.1 and serve it as "Content-type: application/xhtml+xml" with a proper xhtml header that IE bites the bullet and refuses to parse it. So there is no problem sending IE xhtml1.1 with Code:
<?xml version="1.0" encoding="iso-8859-1" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> What I do is send the above xml prolog and dtd and use php to check what the browser supports and if it does not support application/xhtml+xml I just send it a "Content-type: text/html" header. The code will work in IE and browsers that dont support application/xml+xhtml and I send header("Content-type: application/xhtml+xml"); to browsers that do support it (firefox, safari, konqueror, opera) and all is hunky dory. If you are using php then here is some php I pulled from my framework and rewritten as basic php functions that determine what the browser supports and sets a proper mimetype to output headers with. save this as header.php Code:
function set_mimetype()
{
$mimetype = 'text/html';
if(isset($_SERVER['HTTP_ACCEPT']) && stristr($_SERVER['HTTP_ACCEPT'], 'application/xhtml+xml'))
{
/*
* The browser can handle application/xhtml+xml
* We now check Q values to see what the browser actually prefers, html or xhtml.
* if there's a Q value for application/xhtml+xml then also retrieve the Q value for text/html
*/
if(preg_match('/application\/xhtml\+xml;q=0(\.[1-9]+)/i', $_SERVER['HTTP_ACCEPT'], $matches))
{
$xhtml_q = $matches[1];
if(preg_match('/text\/html;q=0(\.[1-9]+)/i', $_SERVER['HTTP_ACCEPT'], $matches))
{
$html_q = $matches[1];
/*
* if the Q value for XHTML is greater than or equal to that for HTML
* then use the "application/xhtml+xml" mimetype
*/
if($xhtml_q >= $html_q)
{
$mimetype = 'application/xhtml+xml';
}
}
}
else // if there was no Q value, then just use the application/xhtml+xml mimetype
{
$mimetype = 'application/xhtml+xml';
}
}
/*
* The w3c validator does not send $_SERVER["HTTP_ACCEPT"] when requesting a document
* but we know it can handle application/xhtml+xml so set the mimetype as that.
*/
if (isset($_SERVER['HTTP_USER_AGENT']) && stristr($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator'))
{
$mimetype = 'application/xhtml+xml';
}
return($mimetype);
}
function output_headers()
{
// Cache-Control for HTTP/1.1, Pragma for older HTTP/1.0
header ('Content-type: ' . set_mimetype() . '; charset='iso-8859-1');
header ('Cache-Control: no-store, no-cache, must-revalidate');
header ('Pragma: no-cache');
header ('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header ('Expires: ' . gmdate('D, d M Y H:i:s', (time()-360000)) . ' GMT');
}
Code:
include('header.php');
output_headers();
xhtml support is in most major browsers and once you get to grips with it you will be outputting leaner/cleaner code. If you use the code above you may want to edit the headers if you want to cache pages etc.
__________________
"I have not failed. I have found 10,000 ways that don't work" - Thomas Edison. "The secret to creativity is knowing how to hide your sources" - Albert Einstein. |
|
||||
|
I can share my ideas so long.
I should prefer to have a class where the construtor takes an integer, indicating page type as one of its parameters. Markup validation could be another parameter e.g. an (associative) array of elements where you specify which you want to use (' ' = Blank for that markup cathegory). This API (class) should automatically test the clients browser. When an updated markup is available, only that (part of the) API should be rewritten. Examples: 1: Naked page. ....... ....... 10: Front page with a <table width="100%" border="0" height="100%"> with one column and three rows one for header, one for body and one for footer. The second row of the table should again contain a new table with one row and three (four) columns, left menu, middle field(s) and right menu. Ideally that outer table should fit 100 % to any screen. There should be no scrolling on the pages. Additional text should only be available on a similar, but not necessarily identically (since it is an internal) page through a pager class like SE SERP's (see Fuecks Vol I chapter 9). The (number of) text / menu lines should fit nicely to the body of the page and be a function of font size and the clients screen size. Content should be supplied via class methods eg. SetFooter, SetHeader, SetLeftMenu, SetRightMenu, SetPageBody, SetPageLeftBody / SetPageRightBody .... That content could be pulled from a database, arrays, files or code and mapped to the class methods. Litterature inspiration: Harry Fuecks "The PHP Anthology: Object Oriented PHP Solutions Vol I" chapter 2 and 9. |
|
|||
|
Quote:
Off Topic Just while i'm posting what do others think of kgun's idea of creating a page class to output common html elements. I've been toying with this idea for some time but never gotten around to implementing it. My idea was to have the class create all the necessary elements (dtd, head section, body tag etc) but none of the actual per page stuff. (This could be put in extended classes maybe. What do you all think? |
|
||||
|
You have to include the xml prolog when you are serving the page as application/xhtml+xml. You are right, it tells the browser to handle it as an xml document.
My page class is a combination of a template and view class. The view class contains code similar to above to determine the browsers capabilities, sends appropriate headers/doctype then queries the template class for the header, body, and footer of the document when $view->display() is called. The template class is just basic variable replacement, a simple if block and a loop for displaying tabular data. The page header, body and footer are the xhtml files with template variable placeholders for the xml prolog, doctype meta tags, page title etc.
__________________
"I have not failed. I have found 10,000 ways that don't work" - Thomas Edison. "The secret to creativity is knowing how to hide your sources" - Albert Einstein. |
|
||||
|
|
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
|
WebProWorld |
Advertise |
Contact Us |
About |
Forum Rules |
MVP's |
Archive |
Newsletter Archive |
Top |
WebProNews
WebProWorld is an iEntry, Inc. ® site - © 2009 All Rights Reserved Privacy Policy and Legal iEntry, Inc. 2549 Richmond Rd. Lexington KY, 40509 |