nested includes not working as intended

M

Mike

Hello,

I'm working on a new site that has a nearly empty index file (variable
location) that includes a template file (set location) which in turn
includes two data files (variable location dependent on index file's
location). This concept worked in PHP and I'm just playing around with it
in ASP to see if it can make my site management easier because I can't move
to Apache for a while.

It seems that the template file can only include relative to itself and also
with specific paths, but it can't include relative to the original index
file. Is there a graceful way around this?

Simplified code below if it helps...

/index.asp:

<!--#include virtual="/templates/_normal.asp"-->

/templates/_normal.asp:

<!--#include file="./_data.asp"-->

<html>
<head>
<title>title</title>
<link rel="stylesheet" href="/styles/style.css">
</head>
<body>
</body>
</html>

/_data.asp - empty

The above only works if I place _data.asp in the same directory as
_normal.asp. That kinda defeats the purpose though. Ideas?

THANKS!
 
B

Bullschmidt

Include paths should be relative to the outtermost file (i.e. the parent
and/or grandparent file).

Best regards,
J. Paul Schmidt, Freelance ASP Web Developer
http://www.Bullschmidt.com
ASP Design Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...
 
M

Mike

Bullschmidt said:
Include paths should be relative to the outtermost file (i.e. the parent
and/or grandparent file).

After much testing I've come to the conclusion that my system seems to be
making it relative to the innermost file. If I have an index.asp located in
any directory that includes a virtual file (/includes/file.asp) and file.asp
tries to include a file that is relative (./foo.asp), it only works if
foo.asp is in the same directory as file.asp. The system doesn't seem to
try to include the foo.asp that is in the same directory as the original
index.asp.

Is it because I'm on IIS 4.0? Or is there a setting that can cause this
behavior that I've accidentally misconfigured? Thanks.
 
M

Mike

Manohar Kamath said:
Why not use absolute paths, starting from the root?

That would be easy, but it would defeat the purpose. My current site has
index files that include absolute things like header and footer and relative
things like content. This is okay, but site changes are mildly challenging
as there are hundreds of index.asp's floating around that might need changes
someday (which is what prompted this project).

I'd rather have hundreds of index files that require absolutely no changes.

So all the index file does is include an absolute file which serves as a
template for my entire site. This file then includes the content, etc.
relative to the original index file.

It works on PHP and I actually had a prototype site that I liked, but a
critical functionality that we have working in a Windows DLL cannot be moved
to PHP because my organization currently refuses to release the code for use
on new servers for security reasons (ironic since I want to move to Apache
FOR security reasons).

Anyway, I just want to become slightly more modular. That's all. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top