Foros de discusión
how can I get $navItems variables from webcontent's template
Yale Yu, modificado hace 12 años.
how can I get $navItems variables from webcontent's template
New Member Mensajes: 6 Fecha de incorporación: 30/03/12 Mensajes recientes
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!
What should I config or how to get navigation information?
Thanks!
amit doshi, modificado hace 11 años.
RE: how can I get $navItems variables from webcontent's template (Respuesta)
Liferay Master Mensajes: 550 Fecha de incorporación: 29/12/10 Mensajes recientes
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.
Hope it helps.
Thanks & Regards,
Amit Doshi
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, modificado hace 11 años.
RE: how can I get $navItems variables from webcontent's template
New Member Mensajes: 6 Fecha de incorporación: 30/03/12 Mensajes recientes
thanks very much