Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other Problem placing code from one file into another.

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #172170
    lkeeney
    Participant

    Say I have an “include” directory located at this address:
    http://www.xxx.com/abc/include

    The file nav2.html is included in this “include” directory.

    I am trying to put the code from the nav2.html file into this file:
    http://www.xxx.com/xyz/index.shtml

    If I use the following code the code from the nav2.html file will be placed in the file.
    <!–#include virtual=”/abc/include/nav2.html” –>

    Why doesn’t this code work?:
    <!–#include virtual=”../include/nav2.html” –>

    I must have done this a hundred times without any problem, but on this new website I am working on it doesn’t work.

    Edit:
    It is late and I am frustrated so if this doesn’t make sense, what I am trying to do is to load a file which is located in a folder, and this folder is one level back from the file into which I want to load this information.

    #172201
    nixnerd
    Participant

    I’m going to guess this is some sort of relative file path issue… but I don’t really know. It looks legit to me as the include structure is basically identical to PHP… aside from the weird crunch/octothorpe nonsense :) I’ve never worked with ASP on any level.

    Just so you know… on a UNIX based system .. means jump up (or I guess down? depending on how you envision it) one level in the directory tree. So… make sure the included file is where you’re saying it is. ../include/nav2.htmlmeans “Go one level closer to the root directory, then go into the ‘include’ directory, then grab ‘nav2.html’.” I don’t know what type of system you’re on or how it works (I know nothing about Windows) but it’s probably the same. Just make sure your files are where they need to be.

    Or… just roll with an absolute file path, in which you tell the main file EXACTLY where the file to be included resides. You do this relative from the ROOT directory… not from the main file.

    Think of the difference in terms of directions. An absolute file path is kind of like exact coordinates. A relative file path is like “Dude, if you’re coming from the highway, just turn right when you hit the stop light. It’s past the liquor store.” It’s relative from where you are at any given time.

    I hope that all made sense :)

    #172205
    Mawaha
    Participant

    In your example the relative path should be

    <!–#include virtual=”../abc/include/nav2.html” –>

    #172259
    lkeeney
    Participant

    I want to thank everyone for their help on this problem. The following morning everything become much clearer.

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘Other’ is closed to new topics and replies.