Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting Constant paths

Status
Not open for further replies.

Jimuniguy

Technical User
Mar 6, 2002
363
GB
Hi,

I am trying to build a site which uses many includes etc, and has many directorys, so files which are on the top level, are also the same as called 5 directorys deep (for instance)

Therefore, how do I set the files so that whereever they are called, they refer to the same spot.

E.g. If i call a script at the top level, e.g. script/mine.js, how can I make sure that a file at /one/two/three/four/mypage.htm also calls script/mine.js

Thanks

James
 
the js file will get handled on the client so you would reference the js from its relative position to the file being viewed.
 
For things other than includes, you could determine the level like this...

thisPage = split(request.servervariables("SCRIPT_NAME"),"/")

path = ""
for x = 1 to uBound(thisPage)
path = path + "../"
next


but for includes, I don't think you can use server side variables to call them...

<!-- #include FILE=&quot;<%path%>filename.ext&quot; --> is probably going to throw an error...

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook
 
In PHP there is a a way of setting a root path for includes, is this possible in ASP?

Thanks
 
james,
say you have a page index.asp in index.asp, which resides in your root folder you reference 2 include files that reside in an includes folder. So in index.asp you reference the includes with includes/include1.asp and includes/include2.asp.

root
--Includes
--Javascript

Now if in one of your includes you are writing out a script tag that references a js script file that is to be used on the client then if your js file is in a folder called Javascript under the root folder you would write out the script tag like so in the include..

<script src=&quot;javascript/java.js&quot;></script>

This code will get interpreted by the client browser and so will resolve the path relative to index.asp which is in the root folder, not relative to the include that wrote the script tag out.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top