Foros de discusión

multi level navigation portlet not for menu bar

thumbnail
jaidshaik shaik, modificado hace 12 años.

multi level navigation portlet not for menu bar

Regular Member Mensajes: 171 Fecha de incorporación: 8/10/10 Mensajes recientes
Hi friends,

I created navigation hook
my requirement is onmouseover show the child pages in navigation portlet.
after i deployed navigation hook child pages are not displaying.....its just displaying main menu item.

please check page.jsp {navigation hook}
any errors please let me know.

<script src="/html/js/jquery.js"></script>
  
  <style>
  
  #nav, #nav ul{
     margin:0;
     padding:0;
     list-style-type:none;
     list-style-position:outside;
     position:relative;
     line-height:1.5em;
 }
  #nav a:link, #nav a:active, #nav a:visited{
    display:block;
    padding:0px 5px;
    border:1px solid #333;
    color:#fff;
    text-decoration:none;
    background-color:#333;
 }

#nav a:hover{
    background-color:#fff;
    color:#333;
}
#nav li{
    float:left;
    position:relative;
}
#nav ul {
    position:absolute;
    width:12em;
    top:1.5em;
    display:none;
}
#nav li ul a{
    width:12em;
    float:left;
}
#nav ul ul{
	top:auto;
	}

#nav li ul ul {
    left:12em;
    margin:0px 0 0 10px;
    }

#nav li:hover ul ul, #nav li:hover ul ul ul, #nav li:hover ul ul ul ul{
    display:none;
    }
#nav li:hover ul, #nav li li:hover ul, #nav li li li:hover ul, #nav li li li li:hover ul{
    display:block;
    }
  
  
  </style>

<script>

function mainmenu(){
jQuery(" #nav ul ").css({display: "none"}); // Opera Fix
jQuery(" #nav li").hover(function(){
		jQuery(this).find('contentnav').css({visibility: "visible",display: "none"}).show(400);
		},function(){
		jQuery(this).find('contentnav').css({visibility: "hidden"});
		});
}

 jQuery(document).ready(function(){
	mainmenu();
});




</script>
	
	



&lt;%@ include file="/html/taglib/ui/navigation/init.jsp" %&gt;

<c:if test="<%= layout != null %>">

	&lt;%
	Layout rootLayout = null;
	boolean hidden = false;

	List selBranch = new ArrayList();

	selBranch.add(layout);
	selBranch.addAll(layout.getAncestors());

	if (rootLayoutType.equals("relative")) {
		if ((rootLayoutLevel &gt;= 0) &amp;&amp; (rootLayoutLevel &lt; selBranch.size())) {
			rootLayout = (Layout) selBranch.get(rootLayoutLevel);
		}
		else {
			rootLayout = null;
		}
	}
	else if (rootLayoutType.equals("absolute")) {
		int ancestorIndex = selBranch.size() - rootLayoutLevel;

		if ((ancestorIndex &gt;= 0) &amp;&amp; (ancestorIndex &lt; selBranch.size())) {
			rootLayout = (Layout) selBranch.get(ancestorIndex);
		}
		else if (ancestorIndex == selBranch.size()) {
			rootLayout = null;
		}
		else {
			hidden = true;
		}
	}
	%&gt;
  [b] <div id="nav">[/b]
	<div class="nav-menu nav-menu-style-<%= bulletStyle %>">
	

		<c:choose>
			<c:when test="<%= (headerType.equals(&quot;root-layout&quot;) &amp;&amp; (rootLayout != null)) %>">

				&lt;%
				String layoutURL = PortalUtil.getLayoutURL(rootLayout, themeDisplay);
				String target = PortalUtil.getLayoutTarget(rootLayout);
				String layoutName = rootLayout.getName(themeDisplay.getLocale());
				%&gt;

				<h2>
					<a href="<%= layoutURL %>" <%="target" %>&gt;&lt;%= layoutName %&gt;</a>
				</h2>
			</c:when>
			<c:when test="<%= headerType.equals(&quot;portlet-title&quot;) %>">
				<h2>&lt;%= themeDisplay.getPortletDisplay().getTitle() %&gt;</h2>
			</c:when>
			<c:when test="<%= headerType.equals(&quot;breadcrumb&quot;) %>">
				   <p id="heading"> <liferay-ui:breadcrumb /></p>
			</c:when>
		</c:choose>
 [b] <div id="contentnav">[/b]
		&lt;%
		if (!hidden) {
			StringBuilder sb = new StringBuilder();

			_buildNavigation(rootLayout, layout, selBranch, themeDisplay, 1, includedLayouts, nestedChildren, sb);

			String content = sb.toString();

			/*if (!nestedChildren) {
				content = StringUtil.replace(content, "<ul class", "< a></ul><ul class"); content="StringUtil.replace(content," "< ul>", "</ul><ul class="\&quot;layouts\&quot;">");
			}*/
		%&gt;

			&lt;%= content %&gt;

		&lt;%
		}
		%&gt;
  </ul></div>		
     </div>
	</div>

</c:if>

&lt;%!
private void _buildNavigation(Layout rootLayout, Layout selLayout, List selBranch, ThemeDisplay themeDisplay, int layoutLevel, String includedLayouts, boolean nestedChildren, StringBuilder sb) throws Exception {
	List layoutChildren = null;

	if (rootLayout != null) {
		layoutChildren = rootLayout.getChildren(themeDisplay.getPermissionChecker());
	}
	else {
		layoutChildren = LayoutLocalServiceUtil.getLayouts(selLayout.getGroupId(), selLayout.isPrivateLayout(), LayoutConstants.DEFAULT_PARENT_LAYOUT_ID);
	}

	if (layoutChildren.size() &gt; 0) {
		StringBuilder tailSB = null;

		if (!nestedChildren) {
			tailSB = new StringBuilder();
		}

		sb.append("<ul class="\&quot;layouts" level-"); sb.append(layoutlevel); sb.append("\">");
       
		for (int i = 0; i &lt; layoutChildren.size(); i++) {
			Layout layoutChild = (Layout)layoutChildren.get(i);

			if (!layoutChild.isHidden() &amp;&amp; LayoutPermissionUtil.contains(themeDisplay.getPermissionChecker(), layoutChild, ActionKeys.VIEW)) {
				String layoutURL = PortalUtil.getLayoutURL(layoutChild, themeDisplay);
				String target = PortalUtil.getLayoutTarget(layoutChild);

				boolean open = false;

				if (includedLayouts.equals("auto") &amp;&amp; selBranch.contains(layoutChild) &amp;&amp; (layoutChild.getChildren().size() &gt; 0)) {
					open = true;
				}

				if (includedLayouts.equals("all")) {
					open = true;
				}

				StringBuilder className = new StringBuilder();

				if (open) {
					className.append("open ");
				}

				if (selLayout.getLayoutId() == layoutChild.getLayoutId()) {
					className.append("selected ");
				}

				sb.append("<li "); if (validator.isnotnull(classname)) { sb.append("class="\&quot;&quot;);" sb.append(classname); sb.append("\" } sb.append(">");
				sb.append("<a "); if (validator.isnotnull(classname)) { sb.append("class="\&quot;&quot;);" sb.append(classname); sb.append("\" } sb.append("href="\&quot;&quot;);" sb.append(layouturl); sb.append(target); sb.append("> ");
				sb.append(layoutChild.getName(themeDisplay.getLocale()));
				sb.append("</a>");

				if (open) {
					StringBuilder layoutChildSB = null;

					if (nestedChildren) {
						layoutChildSB = sb;
					}
					else {
						layoutChildSB = tailSB;
					}

					_buildNavigation(layoutChild, selLayout, selBranch, themeDisplay, layoutLevel + 1, includedLayouts, nestedChildren, layoutChildSB);
				}

				sb.append("</li>");
			}
		}
        
		sb.append("</ul>");

		if (!nestedChildren) {
			sb.append(tailSB);
		}
	}
}
%&gt;




i am looking the output like this for navigation portlet link

Any help in this regard...



thanks
Jaid.shaik
thumbnail
jaidshaik shaik, modificado hace 12 años.

RE: multi level navigation portlet not for menu bar

Regular Member Mensajes: 171 Fecha de incorporación: 8/10/10 Mensajes recientes
Hi,

Any one please let me know about the navigation hook.



thanks
Jaid.Shaik