SSI's in v5

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
jwm1205
Beginner
Beginner
Posts: 4
Joined: Fri Oct 24, 2003 3:46 pm
Location: USA
Contact:

SSI's in v5

Post by jwm1205 »

I recently created SSIs on my home page however when I reference them in subpages they do not follow.

What is the proper code for referencing a SSI from a single directory throughout my site.

I have created

<!--#include file="header.txt" -->

However, it only works in one directory, is it possible to use the SSI above throughout my site?

Thanks.
User avatar
John
 Team
 Team
Posts: 5967
Joined: Sun May 19, 2002 8:23 pm
Location: Phoenix, AZ
Contact:

Re: SSI's in v5

Post by John »

jwm1205 wrote:<!--#include file="header.txt" -->

However, it only works in one directory, is it possible to use the SSI above throughout my site?
It's possible to use anything throughout your site provided it is coded correctly.

In your case, since you said header.txt works on the home page, I have to assume that header.txt is in the same directory as the home page. What you need for the rest of the site (those pages in other directories) is server-relative addressing (this would also apply to the include on the home page). Simply code your include like this...

Code: Select all

<!--#include file="/header.txt" -->
That leading / says look for this file in a location relative to my root server address, regardless of where I'm looking from. So, if your site URL is http://www.mysite.com/, that's where the search for the include begins. Leaving the leading / off says look for the file in the directory I'm in right now, and that is why it's failing for you.
John
jwm1205
Beginner
Beginner
Posts: 4
Joined: Fri Oct 24, 2003 3:46 pm
Location: USA
Contact:

Still having problems...

Post by jwm1205 »

I have tried that. The code I have is as follows on all subsequent pages to my home page:

<!--#include file="/header.txt" -->

However, once I load the page I receive the following error at the top of my page where my header should be placed:

[an error occurred while processing this directive]

The header.txt file is located in my main directory and I am puzzled why it will not duplicate on other .shtml pages within my page. The chmod is 754 for the pages I am trying to access with the SSI.
User avatar
John
 Team
 Team
Posts: 5967
Joined: Sun May 19, 2002 8:23 pm
Location: Phoenix, AZ
Contact:

Post by John »

Try changing that to /header.htm or .html, whichever you use (not .shtml). Just remembered I was doing the same thing the other day and used .js - got the same exact message you did!
John
jkgraham
Beginner
Beginner
Posts: 5
Joined: Fri Oct 24, 2003 6:59 pm

Post by jkgraham »

To do absolute includes use:

<!--#include virtual="/header.txt"-->

or even better, put all your includes in a separate folder:

<!--#include virtual="/includes/header.txt"-->



-Jon
User avatar
Hergio
Milonic God
Milonic God
Posts: 1123
Joined: Wed Jun 12, 2002 7:46 pm
Location: Rochester, NY

Post by Hergio »

yeah ASP pages and the like with automatically parse up and use these includes without any further direction. But because you are using a htm or html file, as John said, you need the s in front so it would be shtml or shtm. The s prefix tells the server before it actually opens the file that there may be includes in the file and it should whip through it and take care of any pre-processing that needs to be done.
Dave Hergert
Software Engineer
"Helping to make the menu better, one :?: at a time."
zjoker
Beginner
Beginner
Posts: 5
Joined: Sat Jan 17, 2004 6:36 am

I find the same problem

Post by zjoker »

I am having the same problem.
Pages are shtml pages.
ssi is as follows:
<!--#include virtual="/includes/ssi_menu.shtml" -->

With this code it shows the 3 .js files that are saved into the includes file, but will not show the menu on preview.
I uploaded all files just in case it needed to be on server to show..still nothing.

Anymore ideas ?

Thanks for any help.
zjoker
zjoker
Beginner
Beginner
Posts: 5
Joined: Sat Jan 17, 2004 6:36 am

tried everything..still nothing

Post by zjoker »

I just seen the post recommending changing the include from a .shtml file to a htm file...That didn't work either...any more suggestions ?
zjoker
Beginner
Beginner
Posts: 5
Joined: Sat Jan 17, 2004 6:36 am

fixed the problem for future ssi posts

Post by zjoker »

ok..after sleeping on the issue, I have now fixed the problem with using the menu as ssi. I simply added " ../" in front of all .js files that I am calling for.
Example:
<script language=JavaScript src="../menu_data.js" type=text/javascript></script>

This will call for the .js file from the correct location.

This will not display the arrow image or other images added. To fix this problem you can call for the image as an abosolute location file..such as http://mysite/images/arrow.gif
User avatar
John
 Team
 Team
Posts: 5967
Joined: Sun May 19, 2002 8:23 pm
Location: Phoenix, AZ
Contact:

Re: fixed the problem for future ssi posts

Post by John »

zjoker wrote:ok..after sleeping on the issue, I have now fixed the problem with using the menu as ssi. I simply added " ../" in front of all .js files that I am calling for.
Example:
<script language=JavaScript src="../menu_data.js" type=text/javascript></script>
That's fine unless/until your site (and calls) moves to other levels. Then you're stuck with changing that call to ../../, ../../../, etc.
John
zjoker
Beginner
Beginner
Posts: 5
Joined: Sat Jan 17, 2004 6:36 am

Re: fixed the problem for future ssi posts

Post by zjoker »

That is true, but that allows me to be able to make changes to my menu for each level rather than each page.
A 6 level website would be able to store 6 menus with various ../../../ for each level represented...Any changes in the futurte would be x6 instead of x1500 (assuming a 1500 page website).
Post Reply