« Return to Thread: LHS navigation menu. How to pass the contents of the portlet to child pages?

LHS navigation menu. How to pass the contents of the portlet to child pages?

by Bojana Lalic :: Rate this Message:

Reply to Author | View in Thread

Some parts of this message have been removed. Learn more about Nabble's security policy.

Hi all

 

I’ve got a left hand navigation on my site which consists of the open content area (can be any portlet) and navigation links. The links work fine and are “passed” through to the pages navigated to from the menu. However, if I for example add a free text portlet with some text in it, it does not get passed through to the pages navigated to from the menu. (Even though the links do).

 

I’ve included the contents of my box.jsp file below... I’ve debugged and it gets to the <content:container id="boxContainer"> and it then stops. Does anyone have any tips as to how to get this to work, and make sure that my portlet contents is passed through?

 

Thanks

 

Bojana

 

 

<div id="left_nav">

<jsp:include page="include/box.jsp" flush="true">

                              <jsp:param name="id" value="left_menu_home"/>

                              <jsp:param name="displayDetailshome" value="true"/>

                         

</jsp:include>

<%!

public void getPageSubTree(   JahiaData jData,

                                int rootPageID,

                                int currentPageID,

                                String theURL,

                                int currentLevel,

                                PageContext pageContext,

                                org.apache.log4j.Logger logger

                                 )

throws JahiaException

{

    JspWriter out = pageContext.getOut();

    JahiaContainerList  linksContainerList = jData.containers().getAbsoluteContainerList( "linkContainer", currentPageID );

 

    boolean editMode = jData.gui().isEditMode();

            boolean hasSubs = false;

 

    currentLevel++;

    try {

        if (linksContainerList != null) {

            Enumeration linksContainerEnum = linksContainerList.getContainers();

                                    if (linksContainerEnum.hasMoreElements()) {

                                          out.print("<ul>");

                                          hasSubs = true;

                                    }

            while (linksContainerEnum.hasMoreElements()) {

                JahiaContainer linksContainer = (JahiaContainer) linksContainerEnum.nextElement();

                ContainerBean linksContainerBean = new ContainerBean(linksContainer,jData.params());

                PageBean linkBean = (PageBean) linksContainerBean.getField("link").getObject() ;

                if (linkBean != null) {

                    int truncSize = editMode ? 30 - (currentLevel * 3) : 40 - (currentLevel * 3);

                    String pageTitle = linkBean.getTitle();

                    logger.debug("pageTitle is " + pageTitle + " for pid " + linkBean.getId());

                    boolean displayLine = false;

                    if (pageTitle != null) {

                        if (pageTitle.length() == 0) {

                            if (editMode) {

                                pageTitle = "<span style='color:#ff0000;'>" + getResourceBundle("noTitle","No title",jData) + "</span>";

                                displayLine = true;

                            }

                        } else {

                            displayLine = true;

                        }

                    } else {

                        if (editMode) {

                            pageTitle = "<span style='color:#ff0000;'>" + getResourceBundle("noTitle","No title",jData) + "</span>";

                            displayLine = true;

                        }

                    }

                    if (displayLine) {

                        // displays page info

                        String state = "";

                        if ( jData.gui().isPageInPath(linkBean.getId()) ) {

                            state = "on";

                        }

                        if ( linkBean.getId() == rootPageID ) {

                            state = "current";

                        }

                        out.println("<li>");

                        //out.println("<td class=\"left"+state+"\"");

                                                                       

                                                                        //boolean isCurrent = false;

                        if (! jData.gui().isPageInPath(linkBean.getId()) && ! "current".equals(state)){

                            //out.println(" onmouseover=\"leftOn(this)\" onmouseout=\"leftOff(this)\"");

                                                                                    //isCurrent = true;

                        }

                        //out.println(">");

 

                        out.println("<a class=\"leftlevel" + currentLevel + " side" + state);

                        out.println("\" href=\"" + linkBean.getUrl() + "\">"+pageTitle+"</a>");

 

                        // displays action buttons on container

                        jData.gui().html().drawBeginActionMenu(linksContainerBean, null, null, false, "", "jahiatemplates.Corporate_portal_templates", null, out);

                        out.println("</li>\n");

 

                        // displays sub links

                        if (linkBean.isInCurrentPagePath()) {

                            getPageSubTree(jData , rootPageID, linkBean.getId(), theURL,currentLevel, pageContext,logger);

                        }

                    }

                } else {

                    if (editMode) {

                        out.println("<li>");

                        out.println("<a href='#' class='leftlevel" + currentLevel +

                            "' style='color:#ff0000;'>" + getResourceBundle("noPage","No page",jData) + "</a>");

                        jData.gui().html().drawBeginActionMenu(linksContainerBean, null, null, false, "", "jahiatemplates.Corporate_portal_templates", null, out);

                        out.println("</li>");

                    }

                }

            } // while (linksContainerEnum.hasMoreElements

 

            // displays action buttons on containerlist

            ContentPage currentPage = ContentPage.getPage(currentPageID);

 

            ContainerListBean linksContainerListBean = new ContainerListBean(linksContainerList,jData.params());

            logger.info("linksContainerListBean.isActionURIsEmpty() for page " + currentPageID + " -> " + linksContainerListBean.isActionURIsEmpty());

            if (! linksContainerListBean.isActionURIsEmpty() ) {

                out.println("<li>");

                //out.println("<span class=\"leftlevel" + currentLevel +"\">");

                jData.gui().html().drawBeginActionMenu(linksContainerListBean , null, theURL + "/images/add.gif", false, "", "jahiatemplates.Corporate_portal_templates", "addPage", out);

                out.println("</li>\n");

            }

                                    if (hasSubs) {

                                          out.print("</ul>");

                                    }

        }

 

    } catch (IOException ioe) {

        logger.debug("IO exception while trying to print left menu for object ", ioe);

    }

}

 

// return the pid of the parent page at the wanted level

public int getPageIDAtLevel(JahiaData jData, int startLevel, int maxLevel)

throws JahiaException

{

    int initLevel = startLevel;

    int currentLevel = jData.gui().getLevel();

    if ( (currentLevel - maxLevel) > initLevel ){

        startLevel = currentLevel - maxLevel;

    }

    Enumeration myPath = jData.page().getContentPagePath(jData.params().getOperationMode(), jData.params().getUser());

    int i = 0;

    while (myPath.hasMoreElements()) {

       ContentPage myPage = (ContentPage) myPath.nextElement();

       i++;

       if (i == (startLevel)) {

           return myPage.getID();

       }

    }

    return -1;

} // end getLevelID

%>

 

<%

/*String maxLevelStr = (String) pageContext.findAttribute("leftMenuMaxDepth");

int maxLevel = 1;

try {

    maxLevel = Integer.parseInt(maxLevelStr);

} catch (NumberFormatException nfe) {

    //System.out.println("left_menu.jsp -> NumberException : " + nfe.toString());

}

*/

int maxLevel = 2;

%>

 

<content:declareField name="isHomeMenu" title="Is child of Home Page" type="Boolean" value="false" />

<jahia:ifNotEditMode><!--</jahia:ifNotEditMode>

<p>Child of Home Page: <content:booleanField name="isHomeMenu" id="isHomeMenu" valueId="isHomeMenuVal" display="true" /></p>

<jahia:ifNotEditMode>--></jahia:ifNotEditMode>

 

<%

int startLevel = jData.gui().getContentHomePage().getID() == jData.page().getID() ? 1 : 2;

//out.print(startLevel);

%>

 

<logic:notEmpty name="isHomeMenuVal">

      <logic:equal name="isHomeMenuVal" value="true">

<%

      startLevel = 1;

      //out.print("got here");

%>

      </logic:equal>

</logic:notEmpty>

<jahiaHtml:actionMenu name="isHomeMenu" namePostFix="" resourceBundle="jahiatemplates.Corporate_portal_templates" useFieldSet="false"/>

 

<%

//out.print(getPageIDAtLevel(jData, 1 ,maxLevel));

//for (Enumeration e = jData.gui().getContentHomePage().getChilds(jData.params()) ; e.hasMoreElements() ;) {

//         out.print(e.nextElement()+"<hr>");

//}

//out.print(jData.gui().getContentHomePage().getChilds(jData.params()));

//out.print(jData.gui().getLevelID(3)+"<hr>");

//int startLevel = 1;

//out.print(startLevel);

int linkCount = 0;

if (!thePrint) {

    %>

   <content:declareContainerList name="linkContainer"

        title="linkContainer"

        titleKey="Link Container"

        bundleKey="<%=resBundleID%>"

    >

        <content:declareContainer>

            <content:declareField name="link"

                title="Link"

                titleKey="link"

                bundleKey="<%=resBundleID%>"

                type="Page"

            />

        </content:declareContainer>

    </content:declareContainerList>

 

    <content:absoluteContainerList name="linkContainer" id="linkContainerList" pageLevel="<%=String.valueOf(startLevel)%>">

        <jahiaHtml:actionMenu name="linkContainerList" namePostFix="" resourceBundle="jahiatemplates.Corporate_portal_templates" useFieldSet="false">

        <content:container id="linkContainer">

            <content:pageField valueId="link" name="link"/>

 

 

            <logic:empty name="link">

                <logic:equal name="currentRequest" property="editMode" value="true">

                    <%

                    linkCount++;

                    if (linkCount == 1) {

                        %><ul><%

                    }

                    %>

                    <li>

                            <a href="#" class="leftlevel1" style="color:#ff0000;"><content:resourceBundle

                            resourceBundle="jahiatemplates.Corporate_portal_templates" resourceName="noPage"

                            defaultValue="No page"/></a>

                            <jahiaHtml:actionMenu name="linkContainer" namePostFix="" resourceBundle="jahiatemplates.Corporate_portal_templates" useFieldSet="false">

                            </jahiaHtml:actionMenu>