Friday 16 February 2007

Apache XSSI Notes (Draft)

As and when I get time, I hope to make some more detailed notes on creating navigation lists using the XSSI portion of apache. This is very much a work in progress - so please bear this in mind if you're reading this at the moment.

I'll start with a very simple XSSI example; this one will instruct apache to work out (from examining the URI) which page is currently open, and to apply a new id attribute name to the relevant page:

The XSSI navigation code

<ul class="navigation">
<li><a class="link" id="home<!--#if expr="(${DOCUMENT_URI}=/index.shtml/)" -->-selected<!--#endif -->" href="index.shtml"><span>Home</span></a></li>
<li><a class="link" id="about<!--#if expr="(${DOCUMENT_URI}=/about/)" -->-selected<!--#endif -->" href="about.shtml"><span>About</span></a></li>
<li><a class="link" id="contact<!--#if expr="(${DOCUMENT_URI}=/contact/)" -->-selected<!--#endif -->" href="contact.shtml"><span>Contact</span></a></li>

In the above code sample, apache pattern matches against the URI given to the browser. I've set up a series of id attributes and given them the same names as the pages themselves.

The Output

Opening the default home page (index.shtml) will produce something like this:

<ul class="navigation">
<li><a class="link" id="home-selected"> href="index.shtml"><span>Home</span></a></li>
<li><a class="link" id="about"> href="about.shtml"><span>About</span></a></li>
<li><a class="link" id="contact"> href="contact.shtml"><span>Contact</span></a></li>

By default, pages that need to be parsed by apache (to make the XSSI code work) should be saved with an .shtml extension.

No comments: