Hi,
I would like to create a menu where the menu options were taken from
an XML file. The reason is that I would be able to update the xml file
(by simply adding new child nodes) after I uploaded new web pages.
Each page would run the same PHP script to create the menu. As the xml
file would supply every page, this would mean less time taken up when
adding new pages. Below is an example of the xml file content:
<?xml...
<menu>
<option title="Home" href="home.php">
<option title="Gallery" href="gallery.php">
<option title="Paintings" href="paintings.php">
<option title="Drawings" href="drawings.php">
<option title="Links" href="links.php">
<option title="Contact" href="contact.php">
</menu>
When the menu is displayed in the browser it would look like this:
Home
Gallery
Links
Contact
Each would contain html (<a href...) to allow it to link to another
page but, for example, if the user clicked the Gallery link the next
page would look like this:
Home
Gallery
Paintings
Drawings
Links
Contact
This would, however, require that the script knows where the user was.
I figured using a GET variable somehow so that the script could open
the correct menus'.
I did manage to create a script that could do what I am asking here.
It also allowed me to add new menu options (which is why I opted to
create this in the first place). The problem was I had to predefine
how many levels the xml tree structure would have. I want to be able
to create a script that can allow any amount of levels to be used and
allow the next page to be able to open the correct menu. For example,
my multi-level xml file may look something like this:
<?xml...
<menu>
<option title="Home" href="home.php">
<option title="News" href="news.php">
<option title="Recent News" href="recentnews.php">
<option title="Archive" href="archive.php">
<option title="About me" href="news.php">
<option title="Disclaimer" href="news.php">
<option title="Gallery" href="gallery.php">
<option title="Paintings" href="paintings.php">
<option title="Drawings" href="drawings.php">
<option title="Links" href="links.php">
<option title="Contact" href="contact.php">
</menu>
As the new menu shows, Gallery (as before) only has the two levels
(i.e. Gallery>Paintings or Gallery>Drawings) whereas Home has three
levels within (i.e. Home>News>Recent News). So when the user is within
the Recent News page, the new menu will look like this:
Home
News
Recent News
Archive
About me
Disclaimer
Gallery
Links
Contact
I figured this would require that the script is passed a variable,
contained in the menu link (GET), from the previous page. The variable
would contain informtion for the same script running on the next page
to open the correct menu from the xml file. This is that part that i
dont know how to do.
How could I pass information from one page to the next for the script
(used by all pages) to open the correct menu? If there are any scripts
that are availble online that could do something similar, please
direct me? If anybody has anything that could point me in the right
direction please comment. Thanks
Burnsy