I am working with Liferay 7 GA 4. At the left side there is the Liefray menu (Control Panel, Users etc...)
I'd like to remove this menu for the normal user and keep it visible only for the admin.
Any one can help me find how can I do this?
Thanks a lot in advance
You need to wrap this code in portal_normal.ftl
in your theme.
<@liferay.control_menu />
You can create a theme context contributor to add a value into the model that will determine if the user should or should not get the menu.
the code could be something like this
Boolean isAdmin = false;
ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
try {
Group group = themeDisplay.getScopeGroup();
PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();
if (themeDisplay.isSignedIn() && groupPermission.contains(permissionChecker, group,
ActionKeys.VIEW_SITE_ADMINISTRATION)) {
isAdmin = true;
}
} catch (PortalException e) {
LOG.warn(e);
}
contextObjects.put("is_site_admin", isAdmin);
The key is to use the permission checker.