473,388 Members | 1,198 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

XML powered all-knowing menu

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
Jul 17 '05 #1
1 2184

Bizt wrote:
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

you don't need passed vars. i see two ways:

1. your xml contains the href and your file has an uri. compare the two
to find out which option the user clicked on(i.e. which file is open
now). i found that unreliable if your content stretches over a couple
of folders.

2. each file contains a value determining it's position in the nav.
that' what i use.

now the structure

1. if you wanna stick with xml:

use DOM XML funtions to find parent/child nodes to find out which
submenus to display. lot of bother for just a nav in my opinion.

2. use an multidimensional array instead of xml

style of

$nav['menu_name']['void'] = "href"; //this would be a main menu item
$nav['menu_name']['submenu1_name'] = "href"; // and it's submenu items
$nav['menu_name']['submenu2_name'] = "href";

each page is contains simply contains info for it's matching array
element. this way you can assign a couple of files to one menu item,
too (i needed that, because there's files on my page which are not
accessible through the nav, but only among each other)

micha

Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Ranger West | last post by:
Hello there, Are there any out-of-the box handhelds that run Linux/Apache/MYSQL and PHP? Does Redhat, Suse, or Gentoo support any handhelds? I know the Zaurus comes close, but I've heard...
1
by: Pim van der Eijk | last post by:
XML 2004 Award voor ''Best Powered XML Site'' De XML gebruikersgroep geeft traditioneel aan het eind van het jaar tijdens het jaarlijkse congres een award aan de persoon of het initiatief die in...
3
by: Robb Gilmore | last post by:
Hi, We have a C#.NET win-forms application that talks to a device plugged into the USB port. Sometimes when severe communications interruptions occur, such as from a burst of ESD electricity,...
0
by: Steve Chen | last post by:
Wireless Search with Summarized Results/Web Pages, powered by Google! We just released a wireless search service. The wireless search service takes the results returned by Google and gives key...
5
by: Robin Johnson | last post by:
Hi, I've written an engine in Javascript for running text adventure games on a web page: http://www.robinjohnson.f9.co.uk/adventure/hamlet.html (That's the only game I've written with it so...
4
by: Woody Splawn | last post by:
Is there such a thing as a Powered By VS.net or VB.net logo? If so, where might one find it so it can be incorporated into a web site?
0
by: John | last post by:
http://www.teenwag.com/search?q=sports+illustrated&btn=Search http://www.teenwag.com/search?q=%09+Antonella+Barba&btn=Search http://www.teenwag.com/search?q=%09+Anna+Nicole+smith&btn=Search ...
0
by: Ed | last post by:
I want to know when the screensaver has kicked in on my monitor so that I can turn off the desk light in my office. Under XP it has worked great. I use the following to check if screensaver is...
7
by: Alfred | last post by:
Hi In Access 2007 (the MDE) The taskbar displays Powered by Microsoft Access. How can I remove it Thanks Alfred
0
by: dahu | last post by:
hi i would like some feedback about my new website : - no Mysql - Only php 5 / XML-NATIVE-DB The xml-db is powered by Sedna (free) + the php-api for it website:...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.