Click here to get back home

multiple instances of a CSS link due to server-side file inclusion and tools requirements

 HomeNewsGroups | Search
 comp.infosystems.www.authoring.html    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
multiple instances of a CSS link due to server-side file inclusion and tools requirements henry 11-18-2008
Posted by henry on November 18, 2008, 12:03 am
Please log in for more thread options
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="TheSiteWideStyles.css" rel="stylesheet"
type="text/css">
....
<head>
...
</head>
<body>
....
<?php
if ($a == 1) { require("ContentChunk1.html"); }
elseif ($a == 2) { require("ContentChunk2.html"); }
elseif ($a == 3) { require("ContentChunk3.html"); }
...
else { require("ContentChunkDefault.html"); }
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="TheSiteWideStyles.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.org 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'


Posted by Scott Bryce on November 18, 2008, 1:51 am
Please log in for more thread options
henry wrote:
<example html snipped>
> In other words, the chunks are just normal HTML files.

They shouldn't be. The chunks should be constructed so that the result
after including one inside the other is a normal html file.

> Question 2: Do other authoring environments handle this differently,
> perhaps more cleverly?

Most of the regulars here use a text editor to write HTML. Yes, a text
editor handles this differently.

> Please: I've heard "Don't use DreamWeaver!" too many times already,
> so there is no need to repeat it.

If you are going to ask a question, you need to be willing to accept a
correct answer.

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

Right. Unfortunately, your method is designed to send invalid HTML to
the browser. You have asked us not to tell you how to solve that problem.


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

The problem is avoided by designing the chunks that make up the
resulting HTML in such a way as to create a valid HTML file after they
are joined together.

> DW actually provides a workaround for this issue, a mechanism called
> "Design-Time Style Sheets".

<snip>

> But I'm concerned that this mechanism is a bit fragile in practice.

I don't know about fragile, but it may be a way to use DW and still get
the results you want.

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

Learn HTML well enough to write it by hand in a text editor. You may be
using the wrong tool for the job. You can't include a complete HTML file
inside another complete HTML file and expect the result to be a valid
HTML file.

Your content chunk should be just that, a content chunk, not a complete
HTML file.

Posted by Bergamot on November 18, 2008, 8:47 am
Please log in for more thread options

henry wrote:
>
> Question 5: Is there a better place to post this question?

Since your issues seem to be focused around Dreamweaver-specific functions and
features, why don't you try a DW forum? They do have their own newsgroups.

--
Berg

Posted by pecan on November 20, 2008, 5:52 am
Please log in for more thread options
henry wrote:
> 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="TheSiteWideStyles.css" rel="stylesheet"
> type="text/css">
> ....
> <head>
> ...
> </head>
> <body>
> ....
> <?php
> if ($a == 1) { require("ContentChunk1.html"); }
> elseif ($a == 2) { require("ContentChunk2.html"); }
> elseif ($a == 3) { require("ContentChunk3.html"); }
> ...
> else { require("ContentChunkDefault.html"); }
> 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="TheSiteWideStyles.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.org 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'
>

The upshot is that the inserts must not have <header> stuff, CSS links,
or even <BODY> tags... it must be just the inserted code. You do not
need to validate each insert, only validate the generated code.

I had a similar issue lately when I was working on a Wordpress site. I
don't (yet) use DW, but I read somewhere recently that there's a setting
in DW which allows you to categorise files as inserts, not full docs.

Posted by Jonathan N. Little on November 20, 2008, 10:27 am
Please log in for more thread options
pecan wrote:

> The upshot is that the inserts must not have <header> stuff, CSS links,
> or even <BODY> tags... it must be just the inserted code. You do not
> need to validate each insert, only validate the generated code.

Exactly what he has been told in his other post!

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com

Similar ThreadsPosted
Changing test with serverside includes February 11, 2006, 11:45 am
multiple link styles without classes? May 20, 2005, 3:21 pm
Can you break a single HTML file into multiple pages like PEGHELP for Pocket PC does? July 27, 2004, 1:49 pm
'Web Test Tools List' of 300 tools updated at Softwareqatest.com May 24, 2006, 11:41 am
css file won't link to xhtml April 20, 2005, 10:15 pm
Link inside the ZIP file ? December 24, 2006, 4:07 am
resolution of images for inclusion to html October 15, 2007, 5:39 am
Hyper link that opens the newest file in a dir? March 25, 2005, 1:43 pm
Are personalized URLs a danger to my Search Engine inclusion? October 2, 2005, 8:11 am
Forcing retrieval of a fresh copy of a file with a link May 30, 2008, 8:47 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Driving a better car - Fuelzilla.com

Cabling site for homeowners and pros alike - Cabling-Design.com

Friends:

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap