Put simply you need to generate an unordered list in HTML, and then use CSS
to style this list, look at Suckerfish dropdown menus:
http://www.htmldog.com/articles/suckerfish/dropdowns/example/#

Gary's code below can build the <ul> for you.

Tim Lucas also has a custom function to do navigation, but I am not sure if
I am allowed to post it on here. I am sure he wouldn't mind ??? I have not
got this to work yet, as I do not know how to use the GetBloodline() method
( anyone ???)


Here is the code that Gary Menzel sent me last year - it works !: 

METHODS TO GET DATA AND RENDER THE JS MENU:
(NOTE1: commented out items are left in to show additional information
available in navigation objects)
(NOTE2: the section that is conditional on the length of the children
array is there to include sibling page titles into the drop-down menu
- ie. pages that all live at the same level of that nav node IF the
nav node itself has no child nav nodes.  This allows a nav item like
"newsletter" to display all it's underlying pages in the nav tree.  If
you dont want this functionality you can comment out or remove the
whole IF statement).

<cffunction name="dump">
        <cfdump var="#Arguments[1]#">
</cffunction>

<cffunction name="getNav" return="struct">
<cfargument name="parentID" type="string" required="yes">
<cfargument name="aRet" type="array" required="yes" default="#ArrayNew(1)#">

        <cfscript>
                var local = StructNew();
                local.navFilter=arrayNew(1);
                local.navfilter[1] = "status IN
(#listQualify(request.mode.lvalidstatus, "'")#)";
                local.qNav = application.factory.oTree.getDescendants(
objectid=Arguments.parentID,
        
depth=1,
        
afilter=local.navFilter
        
);
        </cfscript>

        <cfif local.qNav.RecordCount>
                <cfloop query="local.qNav">
                        <cfscript>
                                local.stData = StructNew();
                                //local.stData.nleft = nleft;
                                //local.stData.nlevel = nlevel;
                                //local.stData.nright = nright;
                                local.stData.objectid = objectid;
                                local.stData.objectname = objectname;
                                //local.stData.parentid = parentid;
                                local.stData.typename = typename;
                                local.stData.children = getNav(objectid);
                                if(ArrayLen(local.stData.children) EQ 0)
                                {
                                        // see if there are any sibling
pages
                                        // need to get the top level
OBJECTID for this NAVID
                                        local.o = createObject("component",
application.types.dmNavigation.typePath);
                                        local.stObj=
local.o.getData(objectid=objectid);
                                        if(ArrayLen(local.stObj.aObjectIDs)
GT 1)
                                        {
                                                for(local.i=2;local.i LE
ArrayLen(local.stObj.aObjectIDs);local.i=local.i+1)
                                                {
                                                        local.o =
createObject("component", application.types.dmHTML.typePath);
                                                        local.stPage =
local.o.getData(objectid=local.stObj.aObjectIDs[local.i]);
//                                                      dump(local.stPage);

                                                        local.stChild =
StructNew();
        
local.stChild.objectid = local.stPage.objectid;
        
local.stChild.objectName = local.stPage.title;
        
local.stChild.children = ArrayNew(1);
        
ArrayAppend(local.stData.children,local.stChild);

                                                }
                                        }
                                }
                                ArrayAppend(Arguments.aRet,local.stData);
                        </cfscript>
                </cfloop>
        </cfif>

        <cfreturn Arguments.aRet>
</cffunction>

<cffunction name="generateNavTree" returntype="string">
<cfargument name="aNav" type="array" required="yes">
<cfargument name="level" type="numeric" default="1">
        <cfset var sRet = "">
        <cfset var local = StructNew()>

<cfsavecontent variable="sRet">
        <cfloop from="1" to="#ArrayLen(Arguments.aNav)#" index="local.i">
                <cfset local.sDaddy = "">
                <cfset local.sChildren = "">
                <cfif ArrayLen(Arguments.aNav[local.i].children)>
                        <cfif Arguments.level GT 1>
                                <cfset local.sDaddy = ' class="daddy"'>
                        </cfif>
                        <cfset local.sChildren =
"<ul>"&generateNavTree(Arguments.aNav[local.i].children,Arguments.level+1)&"
</ul>">
                </cfif>
                <cfoutput><li><a
href="index.cfm?objectid=#Arguments.aNav[local.i].objectid#"#local.sDaddy#>#
Arguments.aNav[local.i].objectname#</a>#local.sChildren#</li></cfoutput>
        </cfloop>
</cfsavecontent>

        <cfreturn sRet>
</cffunction>

HTML PORTION FOLLOWS:

        <div>
                <cfscript>
                        stNav = getNav(application.navid.home);
                </cfscript>

                <ul id="nav">
                        <li><a
href="index.cfm?objectid=#application.navid.home#">Home</a></li>
                #generateNavTree(stNav)#
                </ul>
        </div>


That's it.  You will note that if you remove the portion that includes
sibling pages into the nav (and the bits that are commented out), that
the code is very compact.

Having said all of that, this is only one implementation.  A different
DHTML/XHTML/CSS/JS menu may require a different RENDERING method
(probably not much different if it is based on <ul><li>) - but the
core "get me a nested structure of all my nav nodes" will be very
similar to that used above.  I think too, that it is possible using
the items like NLEFT to order the tree in such a way that it is
returned in hierarchical order which would mean you dont have to use a
recursive call to get the children of a node.  However, I have never
really understood how this works - but I do understand a recursive
call and find the code is generally more elegant.


----------------------------------------------------------------
The information transmitted is intended only for the person or entity to which 
it is addressed and may contain confidential and/or privileged material. Any 
review, retransmission, dissemination or other use of, or taking of any action 
in reliance upon, this information by persons or entities other than the 
intended recipient is prohibited. If you received this in error, please contact 
the sender and delete the material from any computer. It is the responsibility 
of the recipient to ensure that the onward transmission, opening or use of this 
message and any attachments will not adversely affect its systems or data. 
Please carry out such virus and other checks, as you consider appropriate. To 
the fullest extent allowed by law, no responsibility is accepted by Haematology 
& Oncology Clinics of Australasia for any virus damage caused by this message.


---
You are currently subscribed to farcry-dev as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]
Aussie Macromedia Developers: http://lists.daemon.com.au/

Reply via email to