Navigation filters are used to create navigation menus in the Management Bar. You can add as many navigation filters to the Management Bar as your app requires.
You can learn how to configure the navigation filter next.
Configuring the Navigation Filter
Follow these steps to configure the navigation filter:
-
Add the
<liferay-frontend:management-bar-filters>
tag below the<liferay-frontend:management-bar-buttons>
tags, to contain your management bar filters. -
Use the
<liferay-frontend:management-bar-navigation>
tag to add as many navigation menus as your app requires. Use thenavigationKeys
attribute to set the navigation menu options. ThenavigationParam
attribute identifies the parameter to use for the navigation filter value. The default value isnavigation
. If you have more than one navigation menu, you can specify a unique variable with thenavigationParam
to identify each menu. Finally, use theportletURL
attribute to set the URL for the page. Below is an example configuration with one navigation menu:<liferay-frontend:management-bar-filters> <liferay-frontend:management-bar-navigation navigationKeys='<%= new String[] {"all", ["navigation-title"]...} %>' navigationParam="myCustomNavigationVariable" portletURL="<%= portletURL %>" /> </liferay-frontend:management-bar-filters>
If your app doesn’t require any navigation filters, you can just provide the all filter to display everything. If, however, you need to let the user navigate between pages (JSPs) of your app , you can add additional strings to the
navigationKeys
attribute for each page you need. -
Set the navigation filter’s default value with
paramUtil
. For example, the configuration below sets the default navigation filter to all:String navigation = ParamUtil.getString(request, "navigation", "all");
-
If your app has multiple options in a navigation menu, use the
navigationParam
to check the current value. Below is an example code snippet fromcom.liferay.wiki.web
module’spage_iterator.jsp
that checks the navigation menu’s value to render the proper JSP content. Note that it uses thenavigationParam
’s default valuenavigation
to check the current value:if (navigation.equals("all-pages")) { portletURL.setParameter("mvcRenderCommandName", "/wiki/view_pages"); PortalUtil.addPortletBreadcrumbEntry(request, LanguageUtil.get(request, "all-pages"), portletURL.toString()); } else if (navigation.equals("categorized-pages")) { portletURL.setParameter("mvcRenderCommandName", "/wiki/view_categorized_pages"); portletURL.setParameter("categoryId", String.valueOf(categoryId)); } else if (navigation.equals("draft-pages")) { portletURL.setParameter("mvcRenderCommandName", "/wiki/view_draft_pages"); PortalUtil.addPortletBreadcrumbEntry(request, LanguageUtil.get(request, "draft-pages"), portletURL.toString()); }
Now you know how to add navigation filters to a management bar!