3 Replies Latest reply on May 7, 2013 1:34 PM by MuneeswarReddy

    Menu and Sub Menu link

    sbojja

      Hi, I just started to learn Adobe CQ

       

      I have site navigation bar which has 5 items and each navigation item will have sub items. I added text to both the navigation item and sub item but not sure how to link a a particular sub item to a nav item. When I add text in a sub nav item there is no way to say a particular sub item should fall under a navigation item. Can you please let me know if there is a way to accomplish this?

       

      I have created two components one for navigation item and the second one for sub navigation item. And my code looks like this

       

      header.jsp

      <cq:include path="navitem" resourceType="stripe/components/modular/navdropdownitem"/>

      <cq:include path="navitem" resourceType="stripe/components/modular/navdropdownitem"/>

       

       

      navdropdownitem.jsp -- first component

       

      <div class="nav-collapse collapse" style="margin-left: 115px; float:left;">

          <ul class="nav" style="color: #ffffff;">

              <li class="dropdown">

                  <cq:include path="iparnavitem" resourceType="foundation/components/iparsys"/>

                  <a href="#" class="dropdown-toggle" data-toggle="dropdown">

                      <%=navitem%>

                  </a>

                  <cq:include path="parnavsubitem" resourceType="foundation/components/parsys"/>

                  <ul class="dropdown-menu">

                  <%

                  String[]  navsubitems = (String[])request.getSession().getAttribute("navsubitems");

                  if(navsubitems != null)

                  {

                      for(int i=0;i<navsubitems.length ;i++)

                      {

                  %>

                        <li><a href="#"><%=navsubitems[i]%></a></li>

                  <%   

                      }

                  }

                  %>

                  </ul>

              </li>

          </ul>

      </div>     

       

      navdropdownsubitem.jsp

       

      <%

              String[]  navsubitem= properties.get("navsubitem", String[].class);

              HttpSession session = request.getSession();

              session.setAttribute("navsubitems", navsubitem);

      %>

       

       

      Appreciate your help

       

      Thanks

      Sridhar

        • 1. Re: Menu and Sub Menu link
          orotas Level 4

          Honestly I am not sure understand what you are trying to accomplish. I will say one thing is you need to change your calls to reqest.getSession with using jut request.getAttribute and request.setAttribute. Using session attributes for sharing objects across components is definitely not best practice.

           

          Why do you have both an inheritance paragraph system and a normal paragraph system embedded in your first component? Are you assuming that users will drop your second component in the paragraph system and then those components will drive the contents of your drop down? Or is your navigation supposed to be based on the content tree?

          • 2. Re: Menu and Sub Menu link
            sbojja Level 1

            Hi Orotas,

             

            Thanks for your reply.

             

            Yes, I am going to change the request.getSession to request.getAttribute.

             

            You are right with respect to the paragraph system. Users will drop the sub item component and add content that would get dispalyed in the sub menu. Iparagraph is for the main Menu item.  As an example Shoes would be the main menu item and when a user hovers on it I would want to display all the sub menu items in the navigation bar which would be Nike, Adidas, New Balance, Sketchers etc..  My question is lets say if there are multiple items in the navigation bar "Shoes" "Shirts" "Pants" when I add content in the sub items how would I link the correct sub items with "Shoes" "Shirts" and "Pants".  I hope this clears my requirement.

             

            Awaiting your reply

             

            Thanks

            Sridhar

            • 3. Re: Menu and Sub Menu link
              MuneeswarReddy

              Hi Sridhar,

               

              Did you figure out this issue?

              I am also having the same kind of requirement and try to resolve this.

               

              Could you please send me the code snippet to my email id muni.kmca@gmail.com, if you have working code.

               

               

              Thanks

              Muni