View Full Version : Dynamically generating a site menu

10-22-2003, 01:13 PM
Hi all,

my PHP knowledge is still in it's infancy, so to get some practice I thought it would be nice to figure out a way to dynamically serve up a basic site menu using an included PHP script; I'm just trying to get my head around how to approach this.

Basically, I'd like to generate a simple, texted based menu, controlled by (a) variable(s) included in the page it's showing on; the menu I'm envisaging has multiple (about 3 or 4) levels and for every page, only the first level menu choices and all parent levels of the page shown should be visible.

For a first version, an array to hold the necessary info on the menu would more than suffice; if needed, I think I would be capable to convert to using a table lateron.

I've been searching this forum, but nothing useful came up; if anyone can point me to some useful info, an example of something similar, a relevant thread I've missed while searching, or any thoughts on the basic approach, I'm looking forward to it.
I'm not after a full working cut-n-paste solution, just something to get me started.

Thanks in advance.

10-22-2003, 09:09 PM
Your post is not that clear, are you trying to print out some links that resemble a menu? Or do you want to give it some effects like opening/closing? So, for the latter you have to use Javascript and if you know how to make such thing in JS, then it's very easy to make the JS arrays that hold the info with PHP and then let the JS functions work for themselves. What sort of tutorial are you looking for? Do you know how to work with arrays in PHP? If yes, then I don't think that any tutorial is needed in here. I'm confused again :confused: