Example usage for com.liferay.portal.kernel.theme NavItem getChildren

List of usage examples for com.liferay.portal.kernel.theme NavItem getChildren

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.theme NavItem getChildren.

Prototype

public List<NavItem> getChildren() throws Exception 

Source Link

Document

Returns all of child layouts that the current user has permission to access from this navigation item's layout.

Usage

From source file:com.liferay.site.navigation.taglib.servlet.taglib.NavigationTag.java

License:Open Source License

protected List<NavItem> getNavItems(List<NavItem> branchNavItems) throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    List<NavItem> navItems = new ArrayList<>();

    NavItem rootNavItem = null;

    if (_rootLayoutType.equals("relative")) {
        if ((_rootLayoutLevel >= 0) && (_rootLayoutLevel < branchNavItems.size())) {

            rootNavItem = branchNavItems.get(_rootLayoutLevel);
        }/*from   w  w w .  j a  va 2 s  .  co m*/
    } else if (_rootLayoutType.equals("absolute")) {
        if (_rootLayoutLevel == 0) {
            navItems = NavItem.fromLayouts(request, themeDisplay, null);
        } else if (branchNavItems.size() >= _rootLayoutLevel) {
            rootNavItem = branchNavItems.get(_rootLayoutLevel - 1);
        }
    } else if (_rootLayoutType.equals("select")) {
        Layout layout = themeDisplay.getLayout();

        if (Validator.isNotNull(_rootLayoutUuid)) {
            Layout rootLayout = LayoutLocalServiceUtil.getLayoutByUuidAndGroupId(_rootLayoutUuid,
                    layout.getGroupId(), layout.isPrivateLayout());

            rootNavItem = new NavItem(request, themeDisplay, rootLayout, null);
        } else {
            navItems = NavItem.fromLayouts(request, themeDisplay, null);
        }
    }

    if (rootNavItem != null) {
        navItems = rootNavItem.getChildren();
    }

    return navItems;
}