Joomla!
http://forum.joomla.org/

before - the cause of many problems?
http://forum.joomla.org/viewtopic.php?f=42&t=6048
Page 1 of 1

Author:  Geraint [ Thu Sep 15, 2005 11:27 am ]
Post subject:  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

Author:  Geraint [ Thu Sep 15, 2005 11:32 am ]
Post subject:  Re: before - the cause of many problems?

Support for my argument :

http://blogs.msdn.com/ie/archive/2005/0 ... spx#446451

Author:  absalom [ Thu Sep 15, 2005 11:53 am ]
Post subject:  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..

Author:  toubkal [ Thu Sep 15, 2005 12:59 pm ]
Post subject:  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.

Author:  Geraint [ Thu Sep 15, 2005 1:55 pm ]
Post subject:  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

Author:  bfair [ Sat Jan 07, 2006 5:34 am ]
Post subject:  Re: before - the cause of many problems?

According to http://www.quirksmode.org/css/quirksmode.html -
Quote:
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.


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).

Author:  CHCG [ Tue Jan 10, 2006 10:12 am ]
Post subject:  Re: before - the cause of many problems?

Code:
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[/code]

To implement the suggested method the code above, should:

- I drop

[code][/code]// xml prolog
echo '<?xml version="1.0" encoding="'. $iso[1] .'"?' .'>';


alltogether?

- I move the dtd to the very top, i.e. before

Code:
<?php
defined( '_VALID_MOS' ) or die( 'Restricted access' );
??

I would be most grateful if anyone cared to clarify this!!

Author:  absalom [ Tue Jan 10, 2006 10:24 am ]
Post subject:  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.

Author:  kinne [ Wed Feb 01, 2006 10:48 am ]
Post subject:  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:
Geraint wrote:


But there was an interesting answer to this post: http://blogs.msdn.com/ie/archive/2005/07/29/445242.aspx#446507. So it seems that it doesn't really matter if the doctype declaration is not the first line in the code.

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??

Author:  absalom [ Thu Feb 02, 2006 11:49 am ]
Post subject:  Re: before - the cause of many problems?

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:
Geraint wrote:


But there was an interesting answer to this post: http://blogs.msdn.com/ie/archive/2005/07/29/445242.aspx#446507. So it seems that it doesn't really matter if the doctype declaration is not the first line in the code.

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??


There are actually 4 seperate code sequences inside the above code:

The 'access or die' statement, to secure the template:
Code:
defined( "_VALID_MOS" ) or die( "Direct Access to this location is not allowed." );


The ISO language call:
Code:
$iso = split( '=', _ISO );


The XML prolog call:
Code:
echo '<?xml version="1.0" encoding="'. $iso[1] .'"?' .'>';


and the Doctype:
Code:
<!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">


What you need to do to force IE to conform to standards is remove the XML prolog call, and since the ISO call is dependent on the XML prolog, you may as well remove that too!

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.

Author:  kinne [ Fri Feb 03, 2006 8:57 am ]
Post subject:  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...

Author:  karryberry [ Thu Dec 20, 2007 8:09 am ]
Post subject:  Re: before - the cause of many problems?

just take it out, most if not all browsers will not be effected by this small code.

Author:  doktorrr [ Mon Jan 26, 2009 6:06 pm ]
Post subject:  Re: <xml> before <!doctype> - the cause of many problems?

IE doesn't work with this small piece of code.

Author:  Gina23 [ Wed Apr 22, 2009 8:42 am ]
Post subject:  Re: <xml> before <!doctype> - the cause of many problems?

I agree this doesnt help with IE

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/