Click to See Complete Forum and Search --> : include virtual
Arzaic
12-21-2003, 09:14 AM
Alright, this has been bugging me forever and i can't figure it out.
I set up includes for my navigation panel and some other links on every page. i have my included files in the public_html directory, where the index.shtml and other files are, and that works (using <!--#include virtual="/footer.htm" -->)
But when i go into a folder, say, public_html/guest/file.shtml, the include doesn't work on the side panels. i have a file in the public_html/arzaic/story.shtml linked on the page, but it links it as guest/arzaic/story.shtml
how can i fix this?
i guess i have something extremely wrong.
the whole problem lies here
http://www.jadecrux.com
i hope i put this in the right section
simflex
12-21-2003, 09:11 PM
yes, you are in the right forum.
There isn't any difference between include file= and include virtual= as far as functionality is concerned.
However, using virtual path within your directory, means that we are not limited by the location of the file to be included in our pages.
What you must know is that the file to be included when using the virtual include directive must be a text file, and its name may have ".html", ".txt", ".asp" ... extensions.
So ensure that your include complies with above.
If your include directive is in compliance, then I would change to <--#include file = "public_html/footer"
Secondly, it is ok to try this:
<--#include file = "../public_html/footer" when in doubt.
Finally, according to your comment above, all your include files are in public_htm.
In that case, this include:
should change to <!--#include file="public_html/guest/file.shtml" and
<!--#include file="public_html/arzaic/story.shtml"
PeOfEo
12-21-2003, 11:07 PM
This is a no brainer, but let me add it anyway, the include must be taking place from a .asp file, well a server side file in general it can work from a .aspx and a .shtml too, and I have never tried it in other files but probably would work in a code behind too.
MichaelM
12-22-2003, 12:59 PM
It looks like the href attributes in the include file are using relative paths, so when the link is displayed on a page that is served from a subdirectory you're getting the subdirectory path prefixed onto the href, which causes the link to look like:
http://www.jadecrux.com/guest/stories.shtml
instead of
http://www.jadecrux.com/stories.shtml
If you change your hrefs on the anchor tags within your include files, to look like
<a href="/stories.html">Stories</a> or <a href="http://www.jadecrux.com/stories.shtml">Stories</a>
instead of <a href="stories.html">Stories</a>
I think you'll get what you're looking for.
Arzaic
12-23-2003, 07:09 PM
Ah, michealM, i can't believe how obvious that answer was. that fixed it. thanks a lot. Now i just have to fix up the coding a bit so everything works. thanks everyone.