Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Remove items from personal bar menu in 7.2
Hi,
Does anyone know how to remove a menu item in the personal bar in 7.2 ?
For example remove "My Submissions" and "My Workflow Tasks". Is it possible?
Ref. https://github.com/liferay/liferay-portal/blob/master/readme/BREAKING_CHANGES.markdown#move-the-user-menu-out-of-the-product-menu
Thanks
Does anyone know how to remove a menu item in the personal bar in 7.2 ?
For example remove "My Submissions" and "My Workflow Tasks". Is it possible?
Ref. https://github.com/liferay/liferay-portal/blob/master/readme/BREAKING_CHANGES.markdown#move-the-user-menu-out-of-the-product-menu
Thanks
Hi Erik,
I doubt that you can acheive this for the administrator. But for any normal user you can acheive this by simply defining permissions in the roles section. Just follow these steps :-
i ) Go to Control Panel.
ii ) Open Roles.
iii) Select the desired Role ( i.e, if the user for whom you want to hide the "My Submissions" and "My Workflow Tasks" options has the role "Client Member" then select "Client Member") .
iv ) Now go to the "define permissions" menu.
v) There you will see "My Account" Option . Open it.
vi) Now enable or disable the access from there as your requirement.
I doubt that you can acheive this for the administrator. But for any normal user you can acheive this by simply defining permissions in the roles section. Just follow these steps :-
i ) Go to Control Panel.
ii ) Open Roles.
iii) Select the desired Role ( i.e, if the user for whom you want to hide the "My Submissions" and "My Workflow Tasks" options has the role "Client Member" then select "Client Member") .
iv ) Now go to the "define permissions" menu.
v) There you will see "My Account" Option . Open it.
vi) Now enable or disable the access from there as your requirement.
The "My Account" is removed in v7.2, so that is not possible. Can't find any other permission neither which has any impact on this.
For the administrator you can play with a litte of css to "remove" the undesidered elements.
Thanks for your reply.
I'm afraid there is no id or class attributes in the html that can be used to pick specific menu (list) elements to be hidden, so this approach seems not to be an option.
I'm afraid there is no id or class attributes in the html that can be used to pick specific menu (list) elements to be hidden, so this approach seems not to be an option.
Rather try searching for the jsp files inside the " liferay-portal-> tomcat -> webapps -> ROOT -> html " which contains this portlet or menu( It is gonna take some effort in searching ). Then you can create the hook and make changes in that jsp file by importing the custom jsp files from liferay hook configurations. Then from there simply delete the portionof code which is responsible for showing that menu ( My submissions, My workflow taks, etc.). I have done this few times. It will work for you too.
The jsp file uses a tag to render the Personal Menu:
The logic lies within these Liferay classes which have a method to decide if to show its menu entry or not. But I don't know how to override these classes. They are not like service classes which you can extend and give a higher "service.ranking".
This tag gets all classes implementing "PersonalMenuEntry", so it's easy to add a menu-entry by creating such a class, but not to remove one.<liferay-product-navigation:personal-menu expanded="<%= true %>" label="<%= userAvatar %>" />
The logic lies within these Liferay classes which have a method to decide if to show its menu entry or not. But I don't know how to override these classes. They are not like service classes which you can extend and give a higher "service.ranking".
You will need to do some hit and trials here. But be sure to make changes only in the hook so that the original jsp file doesnt gets affected.
All items to display are collected in this class:
https://github.com/liferay/liferay-portal/blob/7.2.0-ga1/modules/apps/product-navigation/product-navigation-personal-menu-web/src/main/java/com/liferay/product/navigation/personal/menu/web/internal/PersonalMenuEntryRegistry.java
They are then converted into JSON and served via MVCResourceCommand:
https://github.com/liferay/liferay-portal/blob/7.2.0-ga1/modules/apps/product-navigation/product-navigation-personal-menu-web/src/main/java/com/liferay/product/navigation/personal/menu/web/internal/portlet/action/GetPersonalMenuItemsMVCResourceCommand.java
You can override that MVCResourceCommand with your clone, which somehow filters out these entries.
In this particular case you could somehow override PersonalMenuEntry component and set isShow() method to false:
https://github.com/liferay/liferay-portal/blob/7.2.0-ga1/modules/apps/portal-workflow/portal-workflow-task-web/src/main/java/com/liferay/portal/workflow/task/web/internal/product/navigation/personal/menu/MyWorkflowTaskPersonalMenuEntry.java
But I am unable to do this properly so far.
https://github.com/liferay/liferay-portal/blob/7.2.0-ga1/modules/apps/product-navigation/product-navigation-personal-menu-web/src/main/java/com/liferay/product/navigation/personal/menu/web/internal/PersonalMenuEntryRegistry.java
They are then converted into JSON and served via MVCResourceCommand:
https://github.com/liferay/liferay-portal/blob/7.2.0-ga1/modules/apps/product-navigation/product-navigation-personal-menu-web/src/main/java/com/liferay/product/navigation/personal/menu/web/internal/portlet/action/GetPersonalMenuItemsMVCResourceCommand.java
You can override that MVCResourceCommand with your clone, which somehow filters out these entries.
In this particular case you could somehow override PersonalMenuEntry component and set isShow() method to false:
https://github.com/liferay/liferay-portal/blob/7.2.0-ga1/modules/apps/portal-workflow/portal-workflow-task-web/src/main/java/com/liferay/portal/workflow/task/web/internal/product/navigation/personal/menu/MyWorkflowTaskPersonalMenuEntry.java
But I am unable to do this properly so far.
If you want to just get rid of some menu items in the personal bar, it will be much easier to use component blacklist:
https://portal.liferay.dev/docs/7-1/user/-/knowledge_base/u/blacklisting-osgi-modules-and-components
For instance, to remove "My Workflow Tasks" open Conrol Panel, then navigate to Configuration -> System settings, then click on Module Container icon in Platform category. Then select Component blacklist from the list and specify
com.liferay.portal.workflow.task.web.internal.product.navigation.personal.menu.MyWorkflowTaskPersonalMenuEntry
as a component's name. After you click on Update button, the item will go away from the personal bar.You may find out the names of the components corresponding to each default menu item by using the gogo console like this.
scr:list | grep PersonalMenuEntry
Of course, if you want to implement some additional functionality over the menu items, you should follow Jan's advice and override MVCResourceCommand.
https://portal.liferay.dev/docs/7-1/user/-/knowledge_base/u/blacklisting-osgi-modules-and-components
For instance, to remove "My Workflow Tasks" open Conrol Panel, then navigate to Configuration -> System settings, then click on Module Container icon in Platform category. Then select Component blacklist from the list and specify
com.liferay.portal.workflow.task.web.internal.product.navigation.personal.menu.MyWorkflowTaskPersonalMenuEntry
as a component's name. After you click on Update button, the item will go away from the personal bar.You may find out the names of the components corresponding to each default menu item by using the gogo console like this.
scr:list | grep PersonalMenuEntry
Of course, if you want to implement some additional functionality over the menu items, you should follow Jan's advice and override MVCResourceCommand.
Thanks, blacklisting works fine.But it would also be nice if one could override some of the PersonalMenuEntry classes and set the logic in the isShow() method with our own code.
I can't say this is the best way of solving the problem (since I'm not so confident with OSGi), but at least it works.
As far as I understand, since every personal menu entry is a separate component implementing PersonalMenuEntry interface, which determines isShow(...) as a default method and just returns "true", and none of the components overrides this method, it's useless to override PersonalMenuEntry using service ranking (you'll just get duplicated entries). The proposed solution is to replace an original component with a custom one. By replacing I mean deactivating the original component when the custom one is activated and vice versa.
This post should be helpful: https://liferay.dev/blogs/-/blogs/extending-osgi-components
The custom component for MyWorkflowTaskPersonalMenuEntry looks like this:
You also may override getLabel() and other methods as you like. After you deploy this component, the original MyWorkflowTaskPersonalMenuEntry will be replaced, if your version of isShow() returns true, or none will be displayed otherwise. After you remove the custom component, the original one should be displayed as usual.
As far as I understand, since every personal menu entry is a separate component implementing PersonalMenuEntry interface, which determines isShow(...) as a default method and just returns "true", and none of the components overrides this method, it's useless to override PersonalMenuEntry using service ranking (you'll just get duplicated entries). The proposed solution is to replace an original component with a custom one. By replacing I mean deactivating the original component when the custom one is activated and vice versa.
This post should be helpful: https://liferay.dev/blogs/-/blogs/extending-osgi-components
The custom component for MyWorkflowTaskPersonalMenuEntry looks like this:
@Component(immediate = true,
property = {
"product.navigation.personal.menu.entry.order:Integer=500",
"product.navigation.personal.menu.group:Integer=200"
}, service = PersonalMenuEntry.class)
public class CustomMyWorkflowsTaskPersonalMenuEntry extends BasePersonalMenuEntry {
private final static String COMPONENT_NAME = "com.liferay.portal.workflow.task.web.internal.product.navigation.personal.menu.MyWorkflowTaskPersonalMenuEntry";
private BundleContext _bundleContext;
private ComponentDescriptionDTO _desc;
@Reference
private ServiceComponentRuntime _serviceComponentRuntime;
@Activate
public void activate(BundleContext bundleContext) throws InvalidSyntaxException {
_bundleContext = bundleContext;
_deactivateOriginalComponent();
}
@Deactivate
public void deactivate() throws InvalidSyntaxException {
_activateOriginalComponent();
_bundleContext = null;
}
private void _deactivateOriginalComponent() throws InvalidSyntaxException {
if (_bundleContext == null) {
return;
}
Collection<servicereference<personalmenuentry>> componentMenuEntries = _bundleContext
.getServiceReferences(PersonalMenuEntry.class, "(component.name=" + COMPONENT_NAME + ")");
for(ServiceReference<personalmenuentry> ref : componentMenuEntries) {
Bundle bundle = ref.getBundle();
_desc = _serviceComponentRuntime.getComponentDescriptionDTO(bundle, COMPONENT_NAME);
_serviceComponentRuntime.disableComponent(_desc);
}
}
private void _activateOriginalComponent() throws InvalidSyntaxException {
if (_desc != null) {
_serviceComponentRuntime.enableComponent(_desc);
}
}
@Override
protected String getPortletId() {
return PortletKeys.MY_WORKFLOW_TASK;
}
@Override
public boolean isShow(PortletRequest portletRequest, PermissionChecker permissionChecker) throws PortalException {
// your logic here...
}
}
</personalmenuentry></servicereference<personalmenuentry>
You also may override getLabel() and other methods as you like. After you deploy this component, the original MyWorkflowTaskPersonalMenuEntry will be replaced, if your version of isShow() returns true, or none will be displayed otherwise. After you remove the custom component, the original one should be displayed as usual.
IMO, the is a rol name "User" that is asigned to all authenticated users. There you can follow the instruction by @Vivek Metha enable or disabled the "Access in Personal Menu" Permission.
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™