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>
</ul>
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>
</ul>
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:
Post a Comment