留言板

RE: how can I get $navItems variables from webcontent's template

Yale Yu,修改在12 年前。

how can I get $navItems variables from webcontent's template

New Member 帖子: 6 加入日期: 12-3-30 最近的帖子
I know that we can get $navItems in theme context, but how can I get navItems in webcontent step by step.

What should I config or how to get navigation information?

Thanks!
thumbnail
amit doshi,修改在11 年前。

RE: how can I get $navItems variables from webcontent's template (答复)

Liferay Master 帖子: 550 加入日期: 10-12-29 最近的帖子
Hi Yale,

As per my knowledge you cannot directly get $nav-items in web-content.

But you can use the service of layout and get the currentlayout and also it's subpages too.

The below code will get you the currentlayout of the page and also it's subpages.

##get the services for layout and group

#set($layoutLocalService = $serviceLocator.findService("com.liferay.portal.service.LayoutLocalService"))
#set($groupLocalService  = $serviceLocator.findService("com.liferay.portal.service.GroupLocalService"))

#set($scopeGroup = $groupLocalService.getGroup($getterUtil.getLong($groupId)))
#set($groupHomeURL = $request.get("theme-display").path-friendly-url-public + $scopeGroup.getFriendlyURL())

#set ($layoutId = $getterUtil.getLong($request.get("theme-display").get("plid")))

##take a layout object
#set($layout = $layoutLocalService.getLayout($layoutId))

#set($layoutforsubmenu = $layoutLocalService.getLayout($getterUtil.getLong($groupId),false,$getterUtil.getLong($layoutId)))

#if ($layoutforsubmenu.hasChildren())
		
			#set($layoutList=$layoutLocalService.getLayouts($getterUtil.getLong($groupId),false,$layoutforsubmenu.getLayoutId()))
			
			#foreach($childLayout in $layoutList)
			
				
						#set($childLink = $groupHomeURL +$childLayout.getFriendlyURL())
						
						#if($layout.getPlid() == $childLayout.getPlid() || ($layout.isHidden() && $layout.getParentPlid() == $childLayout.getPlid()))						
							<a href="$childLink" class="active">$childLayout.getName()</a>
						#else
							<a href="$childLink" class="">$childLayout.getName()</a>
						#end
			
				
			#end
			
		#end



Hope it helps.

Thanks & Regards,
Amit Doshi
Yale Yu,修改在11 年前。

RE: how can I get $navItems variables from webcontent's template

New Member 帖子: 6 加入日期: 12-3-30 最近的帖子
thanks very much