Folks:
As a follow-up to my recent posts, I want to ask some more general questions
about multiple instances of a CSS link in a page as seen by browsers due to
server-side file inclusion. Let me set up my question by providing skeleton
code for two files:
Here's a skeleton of "index.php" :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<link href="TheSiteWi deStyles.css" rel="stylesheet "
type="text/css">
....
<head>
...
</head>
<body>
....
<?php
if ($a == 1) { require("Conten tChunk1.html"); }
elseif ($a == 2) { require("Conten tChunk2.html"); }
elseif ($a == 3) { require("Conten tChunk3.html"); }
...
else { require("Conten tChunkDefault.h tml"); }
endif;
?>
...
</body>
</html>
Here's a skeleton of all the content chunk files:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<link href="TheSiteWi deStyles.css" rel="stylesheet "
type="text/css">
....
<head>
...
</head>
<body>
...
</body>
</html>
In other words, the chunks are just normal HTML files.
I'm showing a naive computation of which content chunk to include, but that
isn't important for my questions.
Question 1: What's the best way of describing this design, in which the
index page determines the basic site appearance, and specific "inner"
content is selected by a computation at load time? (Sorry, I'm self-taught
and working alone, and I don't always get the terminology right.)
Note that linkage to the site-wide CSS file occurs in all files. Why? At
least in the authoring environment I'm using, Dreamweaver CS3, that's the
only way to make the site-wide styles available to all pages. (DW experts
will realize there's a "weasel clause" to this; I'll get to that in a
moment.)
Question 2: Do other authoring environments handle this differently,
perhaps more cleverly?
Please: I've heard "Don't use DreamWeaver!" too many times already, so
there is no need to repeat it.
Wen index.php is loaded, one of the chunks will be included and client will
see two, (repeat, 2) identical css link tags. When I test the page,
validator.w3.or g flags this as an error. Well, no sense in confusing
browsers by sending them invalid code -- some are already confused enough as
it is, right?
Question 3: I think designs based on such an include scheme are very
common. In general, how is this issue avoided -- or, do those page simply
fail the validation test -- or do people not use external css as much as
they should?
DW actually provides a workaround for this issue, a mechanism called
"Design-Time Style Sheets". You can externally mark a specific css link in
a particular file as being valid only at design time. As a result, that
tag is filtered out before the file is uploaded to the server. If I use
that feature and if I eliminate all the header and trailer material in my
content chunks, leaving only stuff that's inside <html>... </html>, all my
pages pass w3c validation. (Woo-Hoo!) But I'm concerned that this
mechanism is a bit fragile in practice.
Question 4: Am I missing something completely obvious that would achieve
the same result without all this trouble? Again, I'm self-taught and I
could be completely oblivious to better ways to do this.
Question 5: Is there a better place to post this question?
TIA,
Henry
remove 'zzz'
As a follow-up to my recent posts, I want to ask some more general questions
about multiple instances of a CSS link in a page as seen by browsers due to
server-side file inclusion. Let me set up my question by providing skeleton
code for two files:
Here's a skeleton of "index.php" :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<link href="TheSiteWi deStyles.css" rel="stylesheet "
type="text/css">
....
<head>
...
</head>
<body>
....
<?php
if ($a == 1) { require("Conten tChunk1.html"); }
elseif ($a == 2) { require("Conten tChunk2.html"); }
elseif ($a == 3) { require("Conten tChunk3.html"); }
...
else { require("Conten tChunkDefault.h tml"); }
endif;
?>
...
</body>
</html>
Here's a skeleton of all the content chunk files:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<link href="TheSiteWi deStyles.css" rel="stylesheet "
type="text/css">
....
<head>
...
</head>
<body>
...
</body>
</html>
In other words, the chunks are just normal HTML files.
I'm showing a naive computation of which content chunk to include, but that
isn't important for my questions.
Question 1: What's the best way of describing this design, in which the
index page determines the basic site appearance, and specific "inner"
content is selected by a computation at load time? (Sorry, I'm self-taught
and working alone, and I don't always get the terminology right.)
Note that linkage to the site-wide CSS file occurs in all files. Why? At
least in the authoring environment I'm using, Dreamweaver CS3, that's the
only way to make the site-wide styles available to all pages. (DW experts
will realize there's a "weasel clause" to this; I'll get to that in a
moment.)
Question 2: Do other authoring environments handle this differently,
perhaps more cleverly?
Please: I've heard "Don't use DreamWeaver!" too many times already, so
there is no need to repeat it.
Wen index.php is loaded, one of the chunks will be included and client will
see two, (repeat, 2) identical css link tags. When I test the page,
validator.w3.or g flags this as an error. Well, no sense in confusing
browsers by sending them invalid code -- some are already confused enough as
it is, right?
Question 3: I think designs based on such an include scheme are very
common. In general, how is this issue avoided -- or, do those page simply
fail the validation test -- or do people not use external css as much as
they should?
DW actually provides a workaround for this issue, a mechanism called
"Design-Time Style Sheets". You can externally mark a specific css link in
a particular file as being valid only at design time. As a result, that
tag is filtered out before the file is uploaded to the server. If I use
that feature and if I eliminate all the header and trailer material in my
content chunks, leaving only stuff that's inside <html>... </html>, all my
pages pass w3c validation. (Woo-Hoo!) But I'm concerned that this
mechanism is a bit fragile in practice.
Question 4: Am I missing something completely obvious that would achieve
the same result without all this trouble? Again, I'm self-taught and I
could be completely oblivious to better ways to do this.
Question 5: Is there a better place to post this question?
TIA,
Henry
remove 'zzz'
Comment