By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,879 Members | 1,809 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,879 IT Pros & Developers. It's quick & easy.

Help with "../", #include path!! (EXPERT PLEASE)

P: n/a
I have two folders in my website...

Folder1 (this is where my #include file is, this is where the style.css is)
--Folder2

(Folder2 is inside of Folder1)

Folder2 contains a file that has this #include statement...

<!--#include file="../include.inc"-->

....obviously the include.inc file is not in the same folder as the HTML
file.

The problem is, that the include.inc also contains this CSS statment...

<link rel="stylesheet" type="text/css" href="style.css" />

....And obviously the path does not have "../" in front of it which means it
is looking inside of
Folder2 for the style.css file. And it doesn't exist there. It is only in
Folder1.

I realize I could solve the problem by putting using the full path like
this...

<link rel="stylesheet" type="text/css" href="/project1/Folder1/style.css" />

....but that would mean that this whole site would have to be in a specific
folder
in order to be run properly. This is unacceptable for this particular
project.

I could also solve the problem by making a duplicate copy of the style.css
file
and putting it in the Folder2 folder, however, I don't want the extra
maintenance
hastle of having to remember that when I change one of the style.css files I
have
to also change the other.

Any other suggestions!?? Help!!?
Jul 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
michaaal wrote:
I could also solve the problem by making a duplicate copy of the style.css
file
and putting it in the Folder2 folder, however, I don't want the extra
maintenance
hastle of having to remember that when I change one of the style.css files I
have
to also change the other.


What OS? You could use a symbolic link to make the "copy" if you're on a
real OS.

--
Mark.
Jul 20 '05 #2

P: n/a
On Fri, 02 Jul 2004 13:24:51 GMT, "michaaal" <re******@verizon.net>
wrote:
I have two folders in my website...

Folder1 (this is where my #include file is, this is where the style.css is)
--Folder2

(Folder2 is inside of Folder1)

Folder2 contains a file that has this #include statement...

<!--#include file="../include.inc"-->

...obviously the include.inc file is not in the same folder as the HTML
file.

The problem is, that the include.inc also contains this CSS statment...

<link rel="stylesheet" type="text/css" href="style.css" />

[and the for the stylesheet URI is wrong in the resulting document]

One possibility you might like to try is to set an environment
variable in your Apache configuration (assuming you're using Apache)
and reference it in the include file.

You could either choose to store the "base URI" of the site in there,
which would make some very odd-looking comment-within-tag markup, or
just put the entire link element in there, which is also perhaps the
more flexible solution since you can then change this entire element
just by editing your config, and the stylesheet won't have to "live"
in the same place relative to the documents:

In httpd.conf,
SetEnv STYLESHEET_REF <link ... href="/path/to/style.css" />
(include the full link element; I just shortened it to keep the line
length sensible)

then, in your include file,
<!--#echo var="STYLESHEET_REF" -->

the SetEnv directive is provided by the mod_env module, so you'll need
that loaded. You can use it from an .htaccess file if you can't or
would rather not mess with the global server config.

Note that this question isn't really an HTML question! You might get
better answers if you ask in one of the comp.infosystems.www.servers.*
groups, and state which server you are running.

The above answer could be applied to other servers, but you'll have to
figure out how to set that environment variable yourself.

-Claire
Jul 20 '05 #3

P: n/a
michaaal wrote:

Folder2 contains a file that has this #include statement...
<!--#include file="../include.inc"-->
The problem is, that the include.inc also contains this CSS statment...
<link rel="stylesheet" type="text/css" href="style.css" />

...And obviously the path does not have "../" in front of it which means it
is looking inside of
Folder2 for the style.css file. And it doesn't exist there. It is only in
Folder1.

In the include file:
<link rel="stylesheet" type="text/css" href="./Folder1/style.css" />

If you maintain the same subfolder naming and placement scheme, this
works wherever you put it.

--
jmm dash list at sohnen-moe dot com
(Remove .TRSPAMTR for email)
Jul 20 '05 #4

P: n/a
Tim
On Fri, 02 Jul 2004 13:24:51 GMT,
"michaaal" <re******@verizon.net> posted:
The problem is, that the include.inc also contains this CSS statment...

<link rel="stylesheet" type="text/css" href="style.css" />

...And obviously the path does not have "../" in front of it which means it
is looking inside of
Folder2 for the style.css file. And it doesn't exist there. It is only in
Folder1.


If you have "folder1/page" and "folder2/other" both "folder1/something" and
"folder2/else" can refer to "folder2/css" by "../folder2/css". In one case
it's backing out and going into the other folder, in the other case it
backs out of the current folder, then goes back into it.

--
If you insist on e-mailing me, use the reply-to address (it's real but
temporary). But please reply to the group, like you're supposed to.

This message was sent without a virus, please delete some files yourself.
Jul 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.