473,320 Members | 1,695 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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

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'

Nov 18 '08 #1
4 2371
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.
Nov 18 '08 #2

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
Nov 18 '08 #3
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 <headerstuff, CSS links,
or even <BODYtags... 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.
Nov 20 '08 #4
pecan wrote:
The upshot is that the inserts must not have <headerstuff, CSS links,
or even <BODYtags... 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
Nov 20 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Ohaya | last post by:
Hi, I'm trying to understand a situation where ASP seems to be "blocking" of "queuing" requests. This is on a Win2K Advanced Server, with IIS5. I've seen some posts (e.g.,...
11
by: Mike | last post by:
Looking to find any information on how to properly configure multiple instances of DB2. This is on Win2k db2 ver 7.2. I am basically looking for information on how the multiple instance settings...
4
by: Yasaswi Pulavarti | last post by:
I have a Aix 5.2 server with DB2 UDB 8.1 I created three different instances using the db2setup utility three times. The default instance is db2inst1. When I su - db2inst2 and su - db2inst3 and...
1
by: Ben Fidge | last post by:
Hi, Our hosting company recently shut-down our site because of the resources it was using on a co-hosted server. Apparently, it was spawning multiple instances of ASPNET_WP.EXE. I'm having a...
11
by: Clark Stevens | last post by:
I just finished a WinForms app in VB.NET. I want to allow the user to be able to run multiple instances of the program like you can with Notepad and Wordpad. The way it is now, once I run the...
10
by: John | last post by:
I currently have a Windows Service that runs Transactions that are very Processor/Memory Intensive. I have a requirement to deploy multiple instances of the Web service on the Same server. Each...
0
by: CNN_news | last post by:
I would like to run multiple instances of TYPO3 (a cms written in PHP) on a single server. You can run multiple websites in two methods: multisite or multiple instances. In multiple...
0
by: rbg | last post by:
Have a web application which uses Data Cache. I need to understand what happens when a new instance of the same web application is created for for serving concurrent clients. What happens when...
6
by: Bob Alston | last post by:
Looking for someone with experience building apps with multiple instances of forms open. I am building an app for a nonprofit organizations case workers. They provide services to the elderly. ...
3
by: =?Utf-8?B?VG9kZA==?= | last post by:
What is the memory footprint of static methods of a windows app running on a server when the server spins up multiple instances of the application? In my envirionment, we have a Citrix server...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.