Reputation: 573
i had used below code but it is not working.
<#assign navItem = objectUtil("com.liferay.portal.kernel.theme.NavItem") />
it give below error.
Caused by: freemarker.core._TemplateModelException: Java constructor "com.liferay.portal.kernel.theme.NavItem.com.liferay.portal.kernel.theme.NavItem(javax.servlet.http.HttpServletRequest, com.liferay.portal.kernel.model.Layout, Map)" takes 3 arguments, but 0 was given.__----_FTL stack trace ("~" means nesting-related)
I had also used below code it is also not working. <#assign navItemClass = portal.getClass().forName("com.liferay.portal.kernel.theme.NavItem")>
Basically i want to retrieve NavItem object in theme and want to use it.
Upvotes: 1
Views: 1773
Reputation: 48087
The scripting context gets a large part of its variables injected by TemplateContextHelper
. In there you can find several relevant values for the underlying problem that you describe in the comment to your question:
layout
is representing the current page (layout is the technical name)layouts
is a collection of all pagesthemeDisplay
navItems
is a collection of all navItems, but you'll have to find the one relating to the current page yourself. It might be easier to go through layout
Browsing through the TemplateContextHelper
sourcecode might give you the hints you need.
Upvotes: 1