Forum Moderators: open

Message Too Old, No Replies

Includes for directories and sub directories

Can I have just one set?

         

kiwibrit

9:37 am on Jun 25, 2006 (gmt 0)

10+ Year Member



I need to re-organize a site into folders at present almost all page files are in the root directory. 301 re-directs will look after SE, and bookmarked pages.

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?

encyclo

1:28 am on Jun 26, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Are the includes showing the same menu or are there different links at different levels?

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?

kiwibrit

8:34 am on Jun 26, 2006 (gmt 0)

10+ Year Member



Thanks for getting back to me. I'm using basic php includes.

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?