Michael Champagne scribbled something along the lines of:
Does anyone have any examples or links to examples of generating a
simple unordered list menu with multiple levels from an XML file? We
are redesigning the navigation on our website and I was hoping to make
this as flexible as possible.
Thanks,
Mike
http://www.php.net/xml
You could have a simple structure like
<?xml version="1.0"?>
<menu xmlns="http://www.example.com/menu" label="Navigati on">
<category label="My stuff">
<entry label="Chimpanz ee" href="/index/chimp"/>
<entry label="Red car" href="/index/car"/>
<category label="My weapons">
<entry label="One-handed sword" href="/index/weaps/sword"/>
<entry label="Battle Axe" href="/index/weaps/axe"/>
</category>
</category>
<category label="Random words">
<entry label="Zilch" href="/index/zilch"/>
<entry label="Squee" href="/index/squee"/>
<entry label="Splurt" href="/index/splurt/">
</category>
</menu>
And all you'd need would be a start-tag and end-tag element handler to
create the following partial HTML:
<h2>Navigatio n</h2>
<ul>
<li class="category ">My stuff<ul>
<li><a href="/index/chimp/">Chimpanze e</a></li>
<li><a href="/index/car/">Red car</a></li>
<li class="category ">My weapons<ul>
<li><a href="/index/weaps/sword/">One-handed sword</a></li>
<li><a href="/index/weaps/axe/">Battle Axe</a></li>
</ul></li>
</ul></li>
<li class="category ">Random words<ul>
<li><a href="/index/zilch/">Zilch</a></li>
<li><a href="/index/squee/">Squee</a></li>
<li><a href="/index/splurt/">Splurt</a></li>
</ul></li>
</ul>
which could for example render like this:
*Navigation*
# /My stuff/
o _Chimpanzee_
o _Red_car_
o /My weapons/
+ _One-handed_sword_
+ _Battle_Axe_
# /Random words/
o _Zilch_
o _Squee_
o _Splurt_
You could also just use XSLT, but that's a little more complicated (IMHO).
The manual should tell you enough that you can do this on your own. If
you want me to write a script for you though, feel free to transfer € 75
to my PayPal account and I'll write you a simple function that does
what I just described.
--
Alan Plum, WAD/WD, Mushroom Cloud Productions
http://www.mushroom-cloud.com/