Home arrow HTML arrow Page 5 - Using SSI to Boost Efficiency
HTML

Using SSI to Boost Efficiency


Have you always thought Server Side Includes (SSI) was too complex? Check out Clay Dowling's tips as he explains some simple SSI directives and how to simplify managing navigation menus.

Author Info:
By: Clay Dowling
Rating: 3 stars3 stars3 stars3 stars3 stars / 7
August 16, 2004
TABLE OF CONTENTS:
  1. · Using SSI to Boost Efficiency
  2. · Enabling SSI
  3. · Simple SSI Directives
  4. · How to Use SSI
  5. · Navigation Menus
  6. · Common HTML Blocks
  7. · Business Considerations

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Using SSI to Boost Efficiency - Navigation Menus
(Page 5 of 7 )

Every website has, or should have, navigation menus to make getting around the site easy. For the most part, these menus are the same on every page.  Even with a complex site, you'll have large numbers of pages with the same menus. That makes them a natural for managing with SSI.

A good example of a navigation menu from my site is below:

<span class="menuitem">
 <a href="/">Home</a>
</span>
<span class="menuitem">
 <a href="index.html">miniCMS</a>
</span>
<span class="menuitem">
 <a href="screenshots.html">Screen Shots</a>
</span>
<span class="menuitem">
 <a href="ptml.html">PTML</a>
</span>
<span class="menuitem">
 <a href="download.html">Download</a>
</span>

If I save this to the file "menu.shtml" I can now put the menu in all of my pages with the directive:

<!--#include virtual="menu.shtml" -->

The files included by a #include directive are also parsed for include directives. This means I can put a uniform page header on all my pages and make the menu part of that header. I'll put this bit of code in a file called "top.shtml":

<div class="banner">
<img src="images/miniCMS.jpeg" alt="miniCMS Logo">
</div>
<div class="menu">
<!--#include virtual="menu.shtml" -->
</div>

Through the magic of CSS we can also use our menu to make a nice navigation bar at the bottom of the page in "bottom.shtml":

<div class="footer">
<hr align="center">
<div class="menu">
<!--#include virtual="menu.shtml" -->
</div>
<p>&copy; 2004 by Megacorp Inc.</p>
<p><a href="mailto:webmaster@megacorp.net">Comments &amp; Questions</a></p>
</div>

Now when we add new pages to our website, the only place where we have to add a link to the page is in "menu.shtml". It will automatically appear in both the main menu at the top of the page and at the little bottom menu.

I have also successfully used a CGI program to generate my menus dynamically. Given how easy it is to maintain a single include file, I only recommend the CGI approach in situations where you're looking to generate a menu that changes based on context.  This could be good, for instance, where the menu shouldn't have an active link for the current page. In that case you'd use #exec instead of #include.


blog comments powered by Disqus
HTML ARTICLES

- HTML5 Boilerplate: Working with jQuery and M...
- HTML5 Boilerplate Introduction
- New API Platform for HTML5
- BBC Adopts HTML 5, Mozilla Addresses Issues
- Advanced Sticky Footers in HTML and CSS
- HTML and CSS Sticky Footers
- Strategy Analytics Predicts HTML5 Phones to ...
- HTML5 Guidelines for Web Developers
- Learning HTML5 Game Programming
- More Engaging CSS3 and HTML Background Effec...
- Engaging HTML and CSS3 Background Effects
- More Web Columns with CSS3 and HTML
- Columns with CSS3 and HTML
- Creating Inline-Block HTML Elements with CSS
- Drag and Drop in HTML5: Parsing Local Files

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 11 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials