Liferay

Liferay User setting navigation override

Jigna Patel
Jigna PatelAug 3, 2022

Problem: Liferay gives lots of user settings. Here we provide a solution for removing or hiding unnecessary settings.

Solution: We want to customize it better to remove the unnecessary settings from the user setting navigation.

Benefits :

  • The Liferay default user setting with some user settings and customize it according to user need.

Prerequisites :

  • Java
  • Liferay portal 7.2 +
  • Basic knowledge of Liferay

Environment Requirements :

  • JDK 11
  • Eclipse/Liferay Dev Studio
  • Liferay Portal

Create a Liferay fragment module using the following steps.

  1. Go to Liferay workspace project → modules → new
  2. Select other → Liferay → Liferay Module Project Fragment
  3. Enter the project name.

Blog Image

4. If you don't have configured the server follow the following steps

  1. If you don't have configured the server follow the following steps
  2. Go to the “windows” setting on the eclipse navigation bar
  3. Select the “show view” -> “other”.

Search servers


Blog Image

4. Now open the “Servers”.

5. Create a new server.

Blog Image

6. Select the Liferay server configuration from the menu and press “next”.

Blog Image

7.Browse your Liferay in your local and select the Liferay.

Blog Image

8. Press “next” and after that press “finish”.

9 The Liferay server has been configured and started.

5. Click on “Next”. And select the following Icon. to browse.

Blog Image

6. the “com.liferay.users.admin.web” jar file of user-admin-web.select the jar.

Blog Image

7. Select the “Add File From OSGI”.

Blog Image

8. Select the following files.

  1. edit_user.jsp:-
  • This file resides in the path “META-INF/resources/edit_user.jsp”.
Blog Image

9. Click on “finish”. Finally, a fragment module has been created.

10. Now, We have to update the “edit_user.jsp” file.

11. we have to add an if statement to only add a custom screen navigator id if the portlet id is equal to my account portlet id. Luckily this is easy to do since my account portlet id is set in the init.JSP

1/* Begin override of My Account */
2//initialize to the real form navigator id.
3
4String formNavigatorId = UserScreenNavigationEntryConstants.SCREEN_NAVIGATION_KEY_USERS;
5
6if (portletName.equals(myAccountPortletId)) {
7	// include the special prefix
8	formNavigatorId = "my.account." + formNavigatorId;
9}
10
11/* End override of My Account */
12

12. We have concat the “my.account” with the formNavigatorId. So We have to pass this updatedFormNavigatorId in <liferay-frontend:screen-navigation/>Key attribute.

1<liferay-frontend:screen-navigation
2	containerCssClass="col-lg-8 registration-sheet"
3	containerWrapperCssClass="container-fluid container-fluid-max-xl  container-from-lg scad-user-setting"
4	context="<%= selUser %>"
5	key="<%= formNavigatorId %>"
6	menubarCssClass="menubar menubar-transparent menubar-vertical-expand-lg"
7	navCssClass="col-lg-3 rounded bg-light registration-tabs p-2"
8	portletURL="<%= portletURL %>"
9/>
10

13. It should be look like following with the updated edit_user.jsp

14. With the help of updatedFormNavigatorId. The Liferay User Navigation Setting Will be hidden and We will get a blank screen if We access the user setting.

15. So, We have to override the Liferay User navigation taglib to show specific user settings.

16. There were two most important factors of liferay-frontend:screen-navigation which are following.

a. ScreenNavigationCategory

  • This category will be responsible for the top-level navigation.
Blog Image

b. ScreenNavigationEntry

  • This Entry will be responsible for the left-side navigation.
Blog Image

17. We have to take The navigation category and the navigation entry taglib classes from the source code that we have to show on the page.

18. For example:-

  • We want to show information and the password in the left navigation on user settings under the “general” category navigation.
  • Then We want the following classes from the taglib from the source code of Liferay. From the following path. The blog follows the Liferay dxp 7.4.13.u24. 
1/liferay-dxp-src-7.4.13.u24/modules/apps/users-admin/users-admin-web/src/main/java/com/liferay/users/admin/web/internal/frontend/taglib/servlet/taglib
  • The classes are as follows.

a. For the Category navigation.

  • UserGeneralScreenNavigationCategory

b. For the Entry navigation

  • BaseUserScreenNavigationEntry
  • UserDisplaySettingsScreenNavigationEntry
  • UserInformationScreenNavigationEntry

UserPasswordScreenNavigationEntry

19. Now, create a Mvc Portlet.

20. Remove the portlet class and resource folder from the portlet

21. Create a constant named “ACCOUNT_PREFIX”. And assign value “”.that we have used in the “edit_user.jsp”. While updating the form navigator.

22. Now add the following respective gradle/Maven dependency.

1compileOnly group: 'com.liferay',name:'com.liferay.users.admin.web'
2

23. This dependency will include all the dependencies related to the User-admin-web.

24. Now create two packages

  • com.liferay.user.setting.taglib.override.category
  • com.liferay.user.setting.taglib.override.entry

25. This package contains the files following.

  • Category :-
  • This package contains the classes that will show the categories on the liferay frontend navigation (Top most navigation).
  • As per the example in the entry package we want the following classes that will be copied from the liferay source code.
  1. UserGeneralScreenNavigationCategory.
  • We have to update the return value of the method “getScreenNavigationKey()”.
  • Concat the ACCOUNT_PREFIX with SCREEN_NAVIGATION_KEY_USERS.
1@Override
2 public String getScreenNavigationKey() {
3       return 
4                  LiferayUserSettingTaglibOverridePortletKeys.ACCOUNT_PREFIX +         UserScreenNavigationEntryConstants.SCREEN_NAVIGATION_KEY_USERS;
5}
6

Entry :-

  • This package contains the classes that will show the entries on the liferay frontend navigation (left navigation).
  • As per the example in the entry package we will add the following classes that will be copied from the liferay source code.
  • BaseUserScreenNavigationEntry
  • We have to update the return value of the method “getScreenNavigationKey()”.
  • Concat the ACCOUNT_PREFIX with SCREEN_NAVIGATION_KEY_USERS.
1@Override
2 public String getScreenNavigationKey() {
3       return 
4                  LiferayUserSettingTaglibOverridePortletKeys.ACCOUNT_PREFIX +         UserScreenNavigationEntryConstants.SCREEN_NAVIGATION_KEY_USERS;
5}
6
  • Now set the JSP renderer on the entry classes that you want to display on the user navigation setting some are following.
  1. UserDisplaySettingsScreenNavigationEntry
  2. UserInformationScreenNavigationEntry
  3. UserPasswordScreenNavigationEntry
  • We have to add the following set method of JSPRenderer in every entry class which redirects to the jsp page.
1@Reference(unbind = "-")
2	public void setJSPRenderer(JSPRenderer jspRenderer) {
3		this.jspRenderer = jspRenderer;
4	}
5
  • Note:-
  • We have to set JSP renderer at every entry class method, Because we
  • can't set the JSP renderer the same as in the original implementation.
  • Otherwise it will be null at runtime.

26. Now deploy both modules to the liferay server and access the user setting.

27. You will see there are only available settings that you have defined in the “liferay-user-setting-taglib-override” module.

Blog Image

© 2026 IGNEK. All rights reserved.

Ignek on LinkedInIgnek on InstagramIgnek on FacebookIgnek on YouTubeIgnek on X