before - the cause of many problems?

Discuss the development and implementation of Joomla! 1.0.x templates here.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
User avatar
Geraint
Joomla! Guru
Joomla! Guru
Posts: 561
Joined: Fri Aug 19, 2005 5:23 pm
Location: Gogledd Cymru

before - the cause of many problems?

Postby Geraint » Thu Sep 15, 2005 11:27 am

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

User avatar
Geraint
Joomla! Guru
Joomla! Guru
Posts: 561
Joined: Fri Aug 19, 2005 5:23 pm
Location: Gogledd Cymru

Re: before - the cause of many problems?

Postby Geraint » Thu Sep 15, 2005 11:32 am


User avatar
absalom
Joomla! Ace
Joomla! Ace
Posts: 1199
Joined: Thu Aug 18, 2005 12:37 am
Location: Melbourne, Australia
Contact:

Re: before - the cause of many problems?

Postby absalom » Thu Sep 15, 2005 11:53 am

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..
Design with integrity : Web accessible solutions
http://www.absalom.biz
http://twitter.com/absalomedia

User avatar
toubkal
Joomla! Hero
Joomla! Hero
Posts: 2860
Joined: Thu Aug 18, 2005 4:35 pm
Location: Cheshire, England
Contact:

Re: before - the cause of many problems?

Postby toubkal » Thu Sep 15, 2005 12:59 pm

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.
Do you want the answer to be as vague as your question?

User avatar
Geraint
Joomla! Guru
Joomla! Guru
Posts: 561
Joined: Fri Aug 19, 2005 5:23 pm
Location: Gogledd Cymru

Re: before - the cause of many problems?

Postby Geraint » Thu Sep 15, 2005 1:55 pm

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

bfair
Joomla! Apprentice
Joomla! Apprentice
Posts: 14
Joined: Tue Oct 25, 2005 12:19 am
Location: Vinita, OK
Contact:

Re: before - the cause of many problems?

Postby bfair » Sat Jan 07, 2006 5:34 am

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

CHCG
Joomla! Explorer
Joomla! Explorer
Posts: 309
Joined: Mon Sep 12, 2005 5:23 am
Location: Stockholm, Sweden

Re: before - the cause of many problems?

Postby CHCG » Tue Jan 10, 2006 10:12 am

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[/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: Select all

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

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

User avatar
absalom
Joomla! Ace
Joomla! Ace
Posts: 1199
Joined: Thu Aug 18, 2005 12:37 am
Location: Melbourne, Australia
Contact:

Re: before - the cause of many problems?

Postby absalom » Tue Jan 10, 2006 10:24 am

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.
Design with integrity : Web accessible solutions
http://www.absalom.biz
http://twitter.com/absalomedia

User avatar
kinne
Joomla! Intern
Joomla! Intern
Posts: 54
Joined: Thu Dec 15, 2005 10:18 am
Location: Brussels

Re: before - the cause of many problems?

Postby kinne » Wed Feb 01, 2006 10:48 am

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/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??
Last edited by kinne on Wed Feb 01, 2006 10:51 am, edited 1 time in total.
> Kinne <

User avatar
absalom
Joomla! Ace
Joomla! Ace
Posts: 1199
Joined: Thu Aug 18, 2005 12:37 am
Location: Melbourne, Australia
Contact:

Re: before - the cause of many problems?

Postby absalom » Thu Feb 02, 2006 11:49 am

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/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: Select all

defined( "_VALID_MOS" ) or die( "Direct Access to this location is not allowed." );


The ISO language call:

Code: Select all

$iso = split( '=', _ISO );


The XML prolog call:

Code: Select all

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


and the Doctype:

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


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

User avatar
kinne
Joomla! Intern
Joomla! Intern
Posts: 54
Joined: Thu Dec 15, 2005 10:18 am
Location: Brussels

Re: before - the cause of many problems?

Postby kinne » Fri Feb 03, 2006 8:57 am

[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...
> Kinne <

karryberry
I've been banned!
Posts: 21
Joined: Wed Dec 19, 2007 10:36 pm

Re: before - the cause of many problems?

Postby karryberry » Thu Dec 20, 2007 8:09 am

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

doktorrr
Joomla! Intern
Joomla! Intern
Posts: 97
Joined: Wed Feb 07, 2007 10:09 pm
Contact:

Re: <xml> before <!doctype> - the cause of many problems?

Postby doktorrr » Mon Jan 26, 2009 6:06 pm

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

Gina23
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Wed Apr 22, 2009 7:13 am

Re: <xml> before <!doctype> - the cause of many problems?

Postby Gina23 » Wed Apr 22, 2009 8:42 am

I agree this doesnt help with IE


Return to “Templates & CSS - 1.0.x”

Who is online

Users browsing this forum: No registered users and 0 guests