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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • michaaal

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


  • Mark Tranchant

    #2
    Re: Help with &quot;../&quot;, #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.

    Comment

    • Claire Tucker

      #3
      Re: Help with &quot;../&quot;, #include path!! (EXPERT PLEASE)

      On Fri, 02 Jul 2004 13:24:51 GMT, "michaaal" <res0gyio@veriz on.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.infosystem s.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

      Comment

      • jmm-list-tr

        #4
        Re: Help with &quot;../&quot;, #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)

        Comment

        • Tim

          #5
          Re: Help with &quot;../&quot;, #include path!! (EXPERT PLEASE)

          On Fri, 02 Jul 2004 13:24:51 GMT,
          "michaaal" <res0gyio@veriz on.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.

          Comment

          Working...