before - the cause of many problems?
Moderator: General Support Moderators
Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
- Geraint
- Joomla! Guru
- Posts: 561
- Joined: Fri Aug 19, 2005 5:23 pm
- Location: Gogledd Cymru
before - the cause of many problems?
The templates that came with $ambo 4.5.2 all dish out a tag before the tag.
According to the XHTML recomendation at w3c.org (http://www.w3.org/TR/xhtml1/):
"An XML declaration is not required in all XML documents; however XHTML document authors are strongly encouraged to use XML declarations in all their documents. Such a declaration is required when the character encoding of the document is other than the default UTF-8 or UTF-16 and no encoding was determined by a higher-level protocol."
Having the xml tag before the doctype appears to stop MSIE 6.0 from going into strict standards mode for some reason. As soon as I removed it my DIV/CSS based layouts all starting behaving perfectly in MSIE and Firefox - before I took it out I'd been forced to resort to using tables!
Do people generally leave it in their templates? Anyone else experienced layout problems that could be caused by this behaviour? Is it something odd about my setup?
Geraint
According to the XHTML recomendation at w3c.org (http://www.w3.org/TR/xhtml1/):
"An XML declaration is not required in all XML documents; however XHTML document authors are strongly encouraged to use XML declarations in all their documents. Such a declaration is required when the character encoding of the document is other than the default UTF-8 or UTF-16 and no encoding was determined by a higher-level protocol."
Having the xml tag before the doctype appears to stop MSIE 6.0 from going into strict standards mode for some reason. As soon as I removed it my DIV/CSS based layouts all starting behaving perfectly in MSIE and Firefox - before I took it out I'd been forced to resort to using tables!
Do people generally leave it in their templates? Anyone else experienced layout problems that could be caused by this behaviour? Is it something odd about my setup?
Geraint
- Geraint
- Joomla! Guru
- Posts: 561
- Joined: Fri Aug 19, 2005 5:23 pm
- Location: Gogledd Cymru
- absalom
- Joomla! Ace
- Posts: 1199
- Joined: Thu Aug 18, 2005 12:37 am
- Location: Melbourne, Australia
- Contact:
Re: before - the cause of many problems?
I recommend people remove it.
XML before the Doctype just causes hassles for cross browser compliance.
That said, I do have an awful lot of legacy templates that don't conform to this, however, I am going through and revising them..
XML before the Doctype just causes hassles for cross browser compliance.
That said, I do have an awful lot of legacy templates that don't conform to this, however, I am going through and revising them..
Design with integrity : Web accessible solutions
http://www.absalom.biz
http://twitter.com/absalomedia
http://www.absalom.biz
http://twitter.com/absalomedia
- toubkal
- Joomla! Hero
- Posts: 2860
- Joined: Thu Aug 18, 2005 4:35 pm
- Location: Cheshire, England
- Contact:
Re: before - the cause of many problems?
I raised this back on the old forum http://forum.mamboserver.com/showthread.php?t=55617
complete with a little demo for people with IE to see the difference it can make to your layout e.g. box model sizing and support for e.g. margin: auto; to center a page.
The demo: http://www.webxite.plus.com/xmlbefore.html
There was not really any feedback on what problems forcing I.E. into standards mode may cause for older browsers.
It sure makes it easier to create sites which work in both I.E.6 and Firefox without resorting to hacks / workarounds.
complete with a little demo for people with IE to see the difference it can make to your layout e.g. box model sizing and support for e.g. margin: auto; to center a page.
The demo: http://www.webxite.plus.com/xmlbefore.html
There was not really any feedback on what problems forcing I.E. into standards mode may cause for older browsers.
It sure makes it easier to create sites which work in both I.E.6 and Firefox without resorting to hacks / workarounds.
Do you want the answer to be as vague as your question?
- Geraint
- Joomla! Guru
- Posts: 561
- Joined: Fri Aug 19, 2005 5:23 pm
- Location: Gogledd Cymru
Re: before - the cause of many problems?
It would be trivial for the templates shipped with Joomla to have a conditional statement before the doctype tag - if the iso encoding is something other than UTF-8 or UTF-16 then show the xml tag otherwise do not.
There's an interesting dicussion, albeit a bit dated, at http://www.webmasterworld.com/forum88/2256.htm.
One problem with switching to UTF-8 encoding throughout is that some of the keys in the MySQL database are then two long (I discovered this trying to restore a database backup using (MySQL Administrator). The backup had been saved as UTF-8 by default and then it barffed when I tried up restore the DB again! If I get the chance I'll try to repeat the exercise to see which the offending tables where (of course they may have been from a 3rd party component and non Joomla!).
Geraint
There's an interesting dicussion, albeit a bit dated, at http://www.webmasterworld.com/forum88/2256.htm.
One problem with switching to UTF-8 encoding throughout is that some of the keys in the MySQL database are then two long (I discovered this trying to restore a database backup using (MySQL Administrator). The backup had been saved as UTF-8 by default and then it barffed when I tried up restore the DB again! If I get the chance I'll try to repeat the exercise to see which the offending tables where (of course they may have been from a 3rd party component and non Joomla!).
Geraint
-
- Joomla! Apprentice
- Posts: 14
- Joined: Tue Oct 25, 2005 12:19 am
- Location: Vinita, OK
- Contact:
Re: before - the cause of many problems?
According to http://www.quirksmode.org/css/quirksmode.html -
That means that if you want it to keep that XML prolog, yet stay in standards compliance mode, you simply switch the doctype to a Transitional doctype. if it's already valid strict, should just be the change of a word and a URL (sometimes).In Explorer 6 Windows, Microsoft implemented one extra rule: if a doctype that triggers strict mode is preceded by an xml prolog, the page shows in quirks mode. This was done to allow web developers to achieve valid pages (which require a doctype) but nonetheless stay in quirks mode.
Most people just don't know what's wrong with their websites. They don't even know they don't know! I'm glad to educate those people.
-
- Joomla! Explorer
- Posts: 309
- Joined: Mon Sep 12, 2005 5:23 am
- Location: Stockholm, Sweden
Re: before - the cause of many problems?
Code: Select all
Hi again! Just a (hopefully) final question:
I have been following the continued discussion regarding the order of the xml declaration and dtd with regards to IE6. The index.php file for rhuk_solarflare begins somewhat different than the examples I have seen illustrating the issue:
[code]<?php
defined( '_VALID_MOS' ) or die( 'Restricted access' );
// needed to seperate the ISO number from the language file constant _ISO
$iso = explode( '=', _ISO );
// xml prolog
echo '<?xml version="1.0" encoding="'. $iso[1] .'"?' .'>';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php mosShowHead(); ?>
<?php
- I drop
Code: Select all
echo '<?xml version="1.0" encoding="'. $iso[1] .'"?' .'>';[/code]
alltogether?
- I move the dtd to the very top, i.e. before
Code: Select all
<?php
defined( '_VALID_MOS' ) or die( 'Restricted access' );
I would be most grateful if anyone cared to clarify this!!
- absalom
- Joomla! Ace
- Posts: 1199
- Joined: Thu Aug 18, 2005 12:37 am
- Location: Melbourne, Australia
- Contact:
Re: before - the cause of many problems?
It's easier just to leave the DTD after the 'access or die' PHP statements, from where I stand.
That way, you know which bits of your template do what, instead of having each piece of functionality spread over many different area.
That way, you know which bits of your template do what, instead of having each piece of functionality spread over many different area.
Design with integrity : Web accessible solutions
http://www.absalom.biz
http://twitter.com/absalomedia
http://www.absalom.biz
http://twitter.com/absalomedia
- kinne
- Joomla! Intern
- Posts: 54
- Joined: Thu Dec 15, 2005 10:18 am
- Location: Brussels
Re: before - the cause of many problems?
This is a very interesting topic. I also found the tutorial on Joomlaya (http://www.joomlaya.com/content/view/221/83/) and I immediately checked the declaration in my own template and found a line before the doctype declaration:
';?>
Moving this piece of code completely ruins my page layout. So I left it there.
Geraint posted the following link to a message in IEBlog:
What is the conclusion? Should the doctype declaration be the first line? If so, what should happen to the XML declaration of the index.php template to avoid it from ruining the design??
';?>
Moving this piece of code completely ruins my page layout. So I left it there.
Geraint posted the following link to a message in IEBlog:
But there was an interesting answer to this post: http://blogs.msdn.com/ie/archive/2005/0 ... spx#446507. So it seems that it doesn't really matter if the doctype declaration is not the first line in the code.Geraint wrote: Support for my argument :
http://blogs.msdn.com/ie/archive/2005/0 ... spx#446451
What is the conclusion? Should the doctype declaration be the first line? If so, what should happen to the XML declaration of the index.php template to avoid it from ruining the design??
Last edited by kinne on Wed Feb 01, 2006 10:51 am, edited 1 time in total.
> Kinne <
- absalom
- Joomla! Ace
- Posts: 1199
- Joined: Thu Aug 18, 2005 12:37 am
- Location: Melbourne, Australia
- Contact:
Re: before - the cause of many problems?
There are actually 4 seperate code sequences inside the above code:kinne wrote: This is a very interesting topic. I also found the tutorial on Joomlaya (http://www.joomlaya.com/content/view/221/83/) and I immediately checked the declaration in my own template and found a line before the doctype declaration:
';?>
Moving this piece of code completely ruins my page layout. So I left it there.
Geraint posted the following link to a message in IEBlog:But there was an interesting answer to this post: http://blogs.msdn.com/ie/archive/2005/0 ... spx#446507. So it seems that it doesn't really matter if the doctype declaration is not the first line in the code.Geraint wrote: Support for my argument :
http://blogs.msdn.com/ie/archive/2005/0 ... spx#446451
What is the conclusion? Should the doctype declaration be the first line? If so, what should happen to the XML declaration of the index.php template to avoid it from ruining the design??
The 'access or die' statement, to secure the template:
Code: Select all
defined( "_VALID_MOS" ) or die( "Direct Access to this location is not allowed." );
Code: Select all
$iso = split( '=', _ISO );
Code: Select all
echo '<?xml version="1.0" encoding="'. $iso[1] .'"?' .'>';
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
It's entirely understandable that removing the entire first line combination ('access or die, ISO and XML prolog') will cause your template to not work. As for the rest of your questions, it's better to leave the 'access or die' statement as the first line as it secures all of your template. You then follow that statement with the doctype, at which point IE renders in standards compliance mode.
Last edited by absalom on Fri Feb 03, 2006 8:26 am, edited 1 time in total.
Design with integrity : Web accessible solutions
http://www.absalom.biz
http://twitter.com/absalomedia
http://www.absalom.biz
http://twitter.com/absalomedia
- kinne
- Joomla! Intern
- Posts: 54
- Joined: Thu Dec 15, 2005 10:18 am
- Location: Brussels
Re: before - the cause of many problems?
[quote=∓quot;absalom"\]
It's entirely understandable that removing the entire first line combination ('access or die, ISO and XML prolog') will cause your template to not work. As for the rest of your questions, it's better to leave the 'access or die' statement as the first line as it secures all of your template. You then follow that statement with the doctype, at which point IE renders in standards compliance mode.
[/quote]
Thank you for this answer.
I did what you suggested, but excet the ISO part of the code, removinig any of the other parts completely ruins the display (menu is not floated left, wrapper is not taken into account,...)
So I left the code as is for now...
It's entirely understandable that removing the entire first line combination ('access or die, ISO and XML prolog') will cause your template to not work. As for the rest of your questions, it's better to leave the 'access or die' statement as the first line as it secures all of your template. You then follow that statement with the doctype, at which point IE renders in standards compliance mode.
[/quote]
Thank you for this answer.
I did what you suggested, but excet the ISO part of the code, removinig any of the other parts completely ruins the display (menu is not floated left, wrapper is not taken into account,...)
So I left the code as is for now...
> Kinne <
-
- I've been banned!
- Posts: 21
- Joined: Wed Dec 19, 2007 10:36 pm
Re: before - the cause of many problems?
just take it out, most if not all browsers will not be effected by this small code.
smile
-
- Joomla! Intern
- Posts: 97
- Joined: Wed Feb 07, 2007 10:09 pm
- Contact:
Re: <xml> before <!doctype> - the cause of many problems?
IE doesn't work with this small piece of code.
-
- Joomla! Fledgling
- Posts: 1
- Joined: Wed Apr 22, 2009 7:13 am
Re: <xml> before <!doctype> - the cause of many problems?
I agree this doesnt help with IE