Forums de discussion

Using NavItem.fromLayouts in Liferay 6.2, how can I retrieve the template?

Valerie Lehmann, modifié il y a 10 années.

Using NavItem.fromLayouts in Liferay 6.2, how can I retrieve the template?

New Member Publications: 11 Date d'inscription: 25/11/13 Publications récentes
I am trying to use NavItem.fromLayouts, but in Liferay 6.2 a third parameter from type Template has been added.

Does anyone know how to retrieve this template so I can use it in this call?
Raghuveer Kanakamedala, modifié il y a 10 années.

RE: Using NavItem.fromLayouts in Liferay 6.2, how can I retrieve the templa

New Member Publications: 5 Date d'inscription: 29/07/13 Publications récentes
You might get away by using null instead of third parameter. Don't know if it works in your context. At least give it a shot.
thumbnail
Rautureau Jérôme, modifié il y a 10 années.

RE: Using NavItem.fromLayouts in Liferay 6.2, how can I retrieve the templa

Junior Member Publications: 52 Date d'inscription: 22/02/08 Publications récentes
Hi,

No... I have already tried with null but with no success...

Someone ?
thumbnail
M J, modifié il y a 9 années.

RE: Using NavItem.fromLayouts in Liferay 6.2, how can I retrieve the templa

Regular Member Publications: 184 Date d'inscription: 01/03/13 Publications récentes
Did anyone find a solution for the above?
thumbnail
M J, modifié il y a 9 années.

RE: Using NavItem.fromLayouts in Liferay 6.2, how can I retrieve the templa

Regular Member Publications: 184 Date d'inscription: 01/03/13 Publications récentes
Any idea? Anyone? Thanks.
thumbnail
M J, modifié il y a 9 années.

RE: Using NavItem.fromLayouts in Liferay 6.2, how can I retrieve the templa

Regular Member Publications: 184 Date d'inscription: 01/03/13 Publications récentes
Figured it. Here are the codes in case if it helps someone.

In the JSP, put the following code and then you can get the navigation page and sub pages.


  TemplateResource templateResource = new StringTemplateResource("0", "# Placeholder");
  Template template = TemplateManagerUtil.getTemplate(TemplateConstants.LANG_TYPE_VM, templateResource, false);
  List<navitem> navItems = NavItem.fromLayouts(request, layouts, template);
  for (NavItem navItem : navItems) {
  ....
  }

</navitem>
thumbnail
Dustin V Kintanar, modifié il y a 9 années.

RE: Using NavItem.fromLayouts in Liferay 6.2, how can I retrieve the templa

New Member Publications: 5 Date d'inscription: 10/04/08 Publications récentes
Hello All,

I needed to use this method display the navigation items for a given GroupId ($navGroupId) within Velocity. In the case it helps anyone else, the code to do so is below.

Thanks,
Dustin


#set($Integer = 0)
#set ($mainLayouts = $layoutService.getLayouts($Integer.parseInt($navGroupId), false, 0))   
#set($newMainLayouts = [])
#foreach ($newLayout in $mainLayouts)
	#if($newLayout.isHidden() == false)
		#set($temp=$newMainLayouts.add($newLayout))			
    #end
#end

#set ($navItemClass = $portal.getClass().forName('com.liferay.portal.theme.NavItem'))
#set ($templateResourceThreadLocal = $portal.getClass().forName('com.liferay.portal.template.TemplateResourceThreadLocal'))
#set ($templateResource = $templateResourceThreadLocal.getTemplateResource('vm'))
#set ($templateManagerUtil = $portal.getClass().forName('com.liferay.portal.kernel.template.TemplateManagerUtil'))
#set ($template = $templateManagerUtil.getTemplate('vm',$templateResource,false))
#set ($newNavItems = $navItemClass.fromLayouts($request, $newMainLayouts,$template))
#set ($nav_items = $newNavItems)
thumbnail
Rautureau Jérôme, modifié il y a 8 années.

RE: Using NavItem.fromLayouts in Liferay 6.2, how can I retrieve the templa

Junior Member Publications: 52 Date d'inscription: 22/02/08 Publications récentes
@ M J

You save my day !

Thanks