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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SSI 3

Status
Not open for further replies.

111011

Technical User
Mar 22, 2002
50
0
0
CA
I have heard that SSI is the way to set up menues because there is only one file to update. I would like to create a side menu with drop down or sliding menu layout using SSI. However, I don't know how to set up the external menu file or how to call the file. Any and all help would be appreciated.
 
The file containing the menu fragment use any name. The file calling the menu MUST have a .SHTML extension. Plus, your Web host must support SSI.

One of my menu files, named "parishmainnav2.htm" looks like this:
Code:
<!-- Standard Navigation Bar -->
<div class="whitetext_m_b">Resources<br />
<a class="leftnav" href="/ministry_all.shtml">Ministries</a><br />
<a class="leftnav" href="/scripture.php">Scripture Study</a><br />
<a class="leftnav" href="/hbulletin.php">Bulletin Archive</a><br />
</div>
.
.
. etc.
The menu is invoked via this code in every page:
Code:
<!-- Standard Navigation Bar -->
<!--#include virtual="/templ/parishmainav2.htm"-->
</div>

Hope this is clear.



Mike Krausnick
Dublin, California
 
I think the slickest way to use SSI, especially if you know a server-side scripting language (perl, php, asp etc.), is to markup pages like this:
Code:
<html>
<head>
  <title>An example page</title>
<!--#exec cgi="/cgi-bin/header.pl"-->
</head>
<body>
<!--#exec cgi="/cgi-bin/top.pl"-->
  <h1>Example</h1>
  <p>Content of the page goes here</p>
<!--#exec cgi="/cgi-bin/bottom.pl"-->
</body>
</html>
Those three scripts serve up the stuff that goes in the head of every page, the stuff that comes before the content and the stuff that comes after, whatever it may be. Because they're scripts and not flat files, they can examine environment variables to determine which page they're producing content for and vary it where required.

Doing it this way meant that I could change one of my sites from table-based to CSS-based layout a while back purely by changing the top & bottom scripts - the individual pages didn't need to be touched.

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
Chris is right, however you don't need CGI to do it... plain old SSI will work too. My page skeleton looks like this:
Code:
<!--#set var='v_pagename' value='Title of this page' -->
<!--#include virtual='/template/header.shtml'-->
<!-- Content starts here -->
&nbsp;
<!-- Content ends here -->
<!--#include virtual='/template/footer.shtml'-->

header.shtml displays everything including the page description at the top of the page (including setting the TITLE to the value of v_pagename) and all the navigation.

footer.shtml does the date-last-modified and 'click here to contact the webmaster' stuff. Very clean. I can change the whole look-and-feel by modifying two files, plus all the CSS.




Mike Krausnick
Dublin, California
 
The benefit of doing it my way, with the <html>, <head> and <body> tags left in the individual files, is that they remain valid HTML files in their own right. If you run them through a validator locally, without including the SSIs, they'll still validate (or not, as the case may be! ).

Also be aware that while the file that loads the includes will normally need to have a [tt].shtml[/tt] extension, the files which are included - header.shtml and footer.shtml in the above example, can have any extension you like.

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
thanks guys. I will be trying out this code today. both at work and home I've been really busy. But what you have sent seems to be exactly what I was looking for.

Klara
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top