Forum Moderators: open
But includes (for navbars and footers) look a little messy. My present solution is to have a set of includes for each folder level. For me that would be a maximum of 3 sets of includes. I can live with that. But is there a way of cutting that down to just one set?
If you want to present different menu options dependent on the location within the site, it is not easy to do with simple SSI. However you can use a more complete server-side scripting language such as PHP or ASP, which will be able to dynamically generate a menu for each page.
What are you trying to do exactly, and what language options are available to you?
So, for example, the side navigation links are kept in a file Templates/sidenavbar.html, as follows:
<div id=sidenavbar>
<ul>
<li><a href="this.htm">This</a></li>
<li><a href="that.htm">That</a></li>
<li><a href="the-other.htm">The other</a></li>
</ul>
</div>
In practice, there is some other stuff which I have omitted here.
Of course, I could use absolute addresses - but I like to have a good play with any additions or changes off line using local host on my computer. In any case, there is other material which also needs re-referencing.
So, at the moment, what I am doing for pages that are in sub-folders is writing a further include, Templates/sublevelsidenavbar:
<div id=sidenavbar>
<ul>
<li><a href="../this.htm">This</a></li>
<li><a href="../that.htm">That</a></li>
<li><a href="../the-other.htm">The other</a></li>
</ul>
</div>
Which worked. But meant more files, more chance for error.
However, I have just discovered that if I use the sub-level include for pages in the root directory, it works there, too. Which pretty much solves the problem, but puzzles me.
I am still playing with this.
As a follow on from your comment, I hadn't thought of dynamically generating the include. Wouldn't that cause a slow-down of the page appearing on screen?