Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 20th, 2005, 08:15 PM
michaaal
Guest
 
Posts: n/a
Default Help with "../", #include path!! (EXPERT PLEASE)

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


  #2  
Old July 20th, 2005, 08:15 PM
Mark Tranchant
Guest
 
Posts: n/a
Default Re: Help with "../", #include path!! (EXPERT PLEASE)

michaaal wrote:
[color=blue]
> 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.[/color]

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

--
Mark.
  #3  
Old July 20th, 2005, 08:15 PM
Claire Tucker
Guest
 
Posts: n/a
Default Re: Help with "../", #include path!! (EXPERT PLEASE)

On Fri, 02 Jul 2004 13:24:51 GMT, "michaaal" <res0gyio@verizon.net>
wrote:
[color=blue]
>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" />
>[/color]
[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
  #4  
Old July 20th, 2005, 08:16 PM
jmm-list-tr
Guest
 
Posts: n/a
Default Re: Help with "../", #include path!! (EXPERT PLEASE)

michaaal wrote:[color=blue]
>
> 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.
>[/color]
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)
  #5  
Old July 20th, 2005, 08:16 PM
Tim
Guest
 
Posts: n/a
Default Re: Help with "../", #include path!! (EXPERT PLEASE)

On Fri, 02 Jul 2004 13:24:51 GMT,
"michaaal" <res0gyio@verizon.net> posted:
[color=blue]
> 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.[/color]

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.
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles