Stephane,

This was the first thing I got to implement in Magnolia and it is really
cool once you get it running.

I don't know much about how much you have looked at the Magnolia API but
I will start with the basics.  If you have already, you should become
very friendly with the Magnolia API. Here are the javadocs:

http://magnolia.sourceforge.net/21/apidocs/index.html

To start off your menu.jsp (or what ever you want to call it) you will
want to get a hierarchy manager to be able to get handles to pages by
their direct path. You can get one with this snippet:

HierarchyManager pageHierarchy =
SessionAccessControl.getHierarchyManager(request);

Next you need to get the root node which your menu will start from.
Check out the Content class in the javadocs for the Magnolia API.

You can get this with the HierarchyManager you set earlier like this:

Content menuRoot = (Content)pageHierarchy.getContent("/path/to/root");

Now that you have the menuRoot, you want to iterate through its children
pages like so:

Iterator subMenuItems = menuRoot.getChildren(ItemType.NT_CONTENT,
ContentHandler.SORT_BY_SEQUENCE).iterator();

In this case I sort the way the items are iterated by the order they are
in the Magnolia page tree.

Now you can step through the Content pages like this:

while (subMenuItems.hasNext()) {
        Content subMenuItem = (Content)subMenuItems.next();
        // Do stuff. Output JS, HTML, whatever.
        String pageName = subMenuItem.getName();
}

This doesn't go into recursion through pages or anything complicated but
you should get the idea by now.  For my menu I collect all my HTML+JS
for my menu up in a StringBuffer and out.prinln(myStrBuffer) when I am
done.  It is tedious to get working right but worth it in the end.  

A working example of this kind thing in a scriptlet used to come with
Magnolia in earlier releases but it got moved into a simple navigation
menu tag:
http://magnolia.sourceforge.net/21/tagreference-cms-util-taglib.html#sim
pleNavigation  You can use this tag to the same effect with some CSS
tweaking but you are limited to the way that that HTML was designed.
You should be able to use my method for any type of DHTML menu scheme
under the sun by outputting the pages info directly in the format the
menu requires.

Enjoy and good luck!

--
Adam Cooper
Talisen Technologies
E: [EMAIL PROTECTED]

-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] 
Sent: Thursday, January 19, 2006 3:32 AM
To: [email protected]
Subject: [magnolia-user] DHTML Menu

Hi everybody,

I would like to feed a dhtml drop menu with my website treenodes and I
would
like to know whether somebody could let me know where to start.
What objects should I use? Is there another way than using the
CurrentActivePage as a start point? 

Many thanks for your help. 

Stephane Gauthier 

----------------------------------------------------------------
for list details see
http://www.magnolia.info/en/magnolia/developer.html
----------------------------------------------------------------

Reply via email to