Theme navigation code question - Websphere

This is a discussion on Theme navigation code question - Websphere ; The following code ( along with some js files) was given to me and is working fine in Portal 6.x. It starts off at the "Home" level and traverses the nodes (labels and pages) at the first level under Home. ...

+ Reply to Thread
Results 1 to 9 of 9

Thread: Theme navigation code question

  1. Theme navigation code question

    The following code ( along with some js files) was given to me and is working fine in Portal 6.x. It starts off at the "Home" level and traverses the nodes (labels and pages) at the first level under Home. I was wondering how to expand this to traverse deeper levels like:<br />
    Home<br />
    dept1 dept2 dept3<br />
    pg1 pg1 pg1<br />
    lblA lblB lblC <br />
    pg2A pg2A pg2A<br />
    lbl2A lbl2A lbl2A<br />
    stuff1 stuff1 stuff1<br />
    stuff2 stuff2 stuff2<br />
    blah1 blah2 blah3<br />
    <br />
    etc. <br />
    <br />
    unsure how to use the following code to traverse an arbitrary number of nested levels beneath Home....though my java/portal skills rival my skills in brain surgery and astrophysics, am thinking that this code could only support a predefined number of levels below a certain level, Home in this case. Any thoughts I'd be most grateful for.<br />
    Phil J.<br />
    <p />
    <br />
    <a href="http://www-128.ibm.com/developerwork.../">Code</a><br />
    if (serviceAvailable) {<br />
    <br />
    NavigationModelProvider provider = (NavigationModelProvider) home.getNavigationModelProvider();<br />
    <br />
    NavigationModel model = provider.getNavigationModel(request, response);<br />
    <br />
    NavigationNode nodeA = (NavigationNode)model.getRoot();<br />
    <br />
    NavigationNode childNode = null;<br />
    <br />
    NavigationNode childNode2ndLevel = null;<br />
    <br />
    if(model.hasChildren(nodeA)) {<br />
    <br />
    Iterator iter = model.getChildren(nodeA);<br />
    <br />
    NavigationNode homeNode = (NavigationNode)iter.next();<br />
    <br />
    Iterator homeIter = model.getChildren(homeNode);<br />
    <br />
    while (homeIter.hasNext()) {<br />
    <p />
    <br />
    childNode = (NavigationNode)homeIter.next(); <br />
    <br />
    selectionCtrl.setSelection(childNode.getObjectID() );%> <br />
    <br />
    <% if(model.hasChildren(childNode)) {

    %> <td>&nbsp; <a class="navfly" onmouseover="mIn ('menu<%=i%>')" onmouseout="mOut ('menu<%=i%>')" href="<%=eUrl%>"><%=childNode.getTitle(localCurren t)%><img id=menu<%=i%> src='<portal-logic:urlFindInTheme file='images/spacer.gif'/>' ></a><br>
    <br />
    <script type="text/javascript" language="JavaScript1.2"><br />
    <br />
    makeLayer ("menu<%=i++%>", "<%=childNode.getTitle(localCurrent) %>=<%=eUrl%>" <%<br />
    <br />
    Iterator childrenIter = model.getChildren(childNode);<br />
    <br />
    while (childrenIter.hasNext()) {<br />
    <br />
    childNode2ndLevel = (NavigationNode)childrenIter.next();<br />
    <br />
    selectionCtrl.setSelection(childNode2ndLevel.getOb jectID());%><br />
    <br />
    ,"<%=childNode2ndLevel.getTitle(localCurrent)%>=<% =eUrl%>"<br />
    <br />
    <%<br />
    <br />
    }<br />
    <br />
    %> );</script>&nbsp;</td><%

    } else { %>
    <br />
    <td valign="top">&nbsp;<a href="<%=eUrl%>"><%=childNode.getTitle(localCurren t) %></a>&nbsp;</td>
    <br />
    <%<br />
    <br />
    }<br />
    <br />
    }<br />
    <br />
    }<br />
    [/Code]

  2. Re: Theme navigation code question

    Well,

    What I think to make it handle any number of levels is to set up some kind of recursive call



    every

    NavigationNode can be used with the NavigationModel to see if it has children via this method



    if(model.hasChildren(nodeA))



    So you would need to keep checking the nodes to see if they had children and then display them.



    One thing to keep in mind is that this can get expensive performance wise, as by default, portal does not load the full set of pages, and waits until they are needed to load.





    IBM Certified System Administrator -- WebSphere Portal V6.0, V5.1, V5.0

    IBM Certified Solution Developer -- WebSphere Portal V5.1, v6.0



    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM

  3. Re: Theme navigation code question

    Many thanks, Jim! I think I could get by with maybe 1 or two levels below. Recursion would be a nasty business here and not terribly efficient.<br />
    <br />
    I tried fiddling with today, getting many purple & blue "screens of death" with jsp errors and even managed to cause the server to stop. If I can add just one more level I think that will suffice, but I barely know what I am looking at.<br />
    <br />
    Am thinking :<br />
    <% if(model.hasChildren(childNode)) {
    %> <td>&nbsp; <a class="navfly" onmouseover="mIn ('menu<%=i%>')" onmouseout="mOut ('menu<%=i%>')" href="<%=eUrl%"><br />
    <%=childNode.getTitle(localCurrent)%><img id=menu<%=i%> src='<portal-logic:urlFindInTheme file='images/ spacer.gif'/>' ></a><br>
    <script type="text/javascript" language="JavaScript1.2"><br />
    makeLayer ("menu<%=i++%>", "<%=childNode.getTitle(localCurrent) %>=<%=eUrl%>" <%<br />
    Iterator childrenIter = model.getChildren(childNode);<br />
    while (childrenIter.hasNext()) {<br />
    childNode2ndLevel = (NavigationNode)childrenIter.next();<br />
    selectionCtrl.setSelection(childNode2ndLevel.getOb jectID());%><br />
    ,"<%=childNode2ndLevel.getTitle(localCurrent)%>=<% =eUrl%>"<br />
    <%<br />
    <------------------------------------maybe here is where I need to add code for another level? <br />
    }<br />
    %> );</script>&nbsp;</td><%
    } else { %>
    <td valign="top">&nbsp;<a href="<%=eUrl%>"><%=childNode.getTitle(localCurren t) %></a>&nbsp;</td>
    <%<br />
    }<br />
    }<br />
    } <br />
    <br />
    Thanks!<br />
    <br />
    Phil J.

  4. Re: Theme navigation code question

    Yes that is correct,

    Just do the following check

    if(model.hasChildren(childNode2ndLevel))

    Then iterate through those children on down




    IBM Certified System Administrator -- WebSphere Portal V6.0, V5.1, V5.0

    IBM Certified Solution Developer -- WebSphere Portal V5.1, v6.0



    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM


  5. Re: Theme navigation code question

    Thanks Jim,



    I fiddled around with this today with no great progress. Do you know of any full-featured examples that will allow something like this:

    http://www.dynamicdrive.com/dynamicindex1/hvmenu/horizon.htm



    This portal navigation has me pretty dazed and confused!



    thanks!



    Phil J.

  6. Re: Theme navigation code question

    I know of no examples, but looking into it you would need to put the js code into a jsp and then use the model spi to generate the links and populate them into the following areas



    Menu2_1_1=new Array("CNN","http://www.cnn.com","",0,20,150);

    67 Menu2_1_2=new Array("ABCNews","http://www.abcnews.com","",0);

    68





    IBM Certified System Administrator -- WebSphere Portal V6.0, V5.1, V5.0

    IBM Certified Solution Developer -- WebSphere Portal V5.1, v6.0



    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM

  7. Re: Theme navigation code question

    Thanks, Jim - I was able to do that in topNav.jspf ok using a known structure and unique names of the pages.



    Is there any way to get a count of child nodes as in something like:

    model.ChildCount(childNode2ndLevel)) so that if I have:



    top level Pets

    2nd level Dogs

    3rd level Fido

    Frisky

    Fluffy

    2level Cats

    3rd level Mitten

    Killer

    Tiger

    Spot



    that model.ChildCount(Dogs) would get me 3, model.ChildCount(Cats) would get me 4 and

    model.ChildCount(Pets) would get me 2? (or whatver property I'd look at!)



    thanks,



    Phil J.

  8. Re: Theme navigation code question

    nothing that I know of is available in the current SPI, will do what you are looking for



    IBM Certified System Administrator -- WebSphere Portal V6.0, V5.1, V5.0

    IBM Certified Solution Developer -- WebSphere Portal V5.1, v6.0



    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM

  9. Re: Theme navigation code question

    Hmm - that is most unfortunate, since such would be handy to have to know in advance how many items are in the collection of child elements. Otherwise you would have to iterate through the nodes twice to build the nice multilevel fly out nav menu I sent the link for a couple of days ago : http://www.dynamicdrive.com/dynamicindex1/hvmenu/horizon.htm



    Staticly, this from that script:

    Menu2_1_1=new Array("CNN","http://www.cnn.com","",0,20,150);

    explodes to 5 lines when done from the jsp. Doing dynamically I'd need to already know how many children there are of a particular menu node.



    has anyone done any dynamic multi-level flyout menus in portal? Surely.....



    Phil J.

+ Reply to Thread