How To Use User Group Page Templates
Table of Contents [-]
- User Group Page Templates
- Page Composition Through Several User Groups
This article describes the new functionalities incorporated in Liferay 5.1 to allow a more flexible customization of the default pages for the users of Liferay Portal. Specifically it describes how to configure the pages associated to user groups to provide a customized set of pages and portlets to the users that belong to those user groups.
Liferay allows users to have a personal set of public and private pages that each user can customize at will. The default configuration of those pages can be determined by the portal administrator through the portal.properties file and optionally by providing such configuration in a LAR file.
This method provides the same configuration for the personal pages of all users. In some cases it is desired to be able to provide a different configuration to each user depending on his or her profile. For example, in a portal for a University students, staff and undergraduates would get different default pages and portlets. Also within each of these groups there are subgroups that also affect the desired default configuration.
To offer a more flexible solution for these scenarios. a new mechanism was implemented based on Liferay's user groups. Portal administrators can now configure page templates within a user group. When a user is assigned to the user group, the configured pages are copied directly to the user's personal pages.
Note: the screenshots in this article show the old classic theme because they were taken right before it was revamped for 5.1. For that reason they'll be slightly different to what you'll find in an out-of-the-box Liferay 5.1 version.
User Group Page Templates #
Defining page templates for a user group #
The page templates of a given user group can be administered using the Enterprise Admin portlet. The User Groups tab lists all the existing user groups and allows performing several actions on each of them.
By selecting the new Manage Pages action the administrator will access the common Liferay UI for creating pages and organizing them in a hierarchy.
Note that it is possible to create both public and private pages. Each set will be used as templates to be copied to the user's personal public or private page sets respectively when the user becomes a member of the user group.
In the screen shot above, the administrator has created a new private page called You are a student within the Student2 user group. Since the page created is a portlet page, the administrator can now click the View Pages button to open the page and add as many portlets as desired to that page and configure them as needed. Let's assume for this example that the Loan Calculator and Calendar portlets are selected.
Applying the page templates by assigning members to the user group #
The next step will be to assign an existing user to that group to verify that the page template is copied as a user's private page. To that end the Assign Members action has to be selected back in the list of available user groups.
By clicking the Available tab in the next screen, a list of all available users is shown. From that list one or more users can be selected to make them members of the user group. When the Update Associations button is clicked, the users become members of the group and copies of any public or private page templates which are configured for the user group are copied to their page sets.
In the previous example, a user that already had an existing page called Welcome will now have a new page called You Are A Student the next time she accesses her private pages. That page will contain two portlets: Loan Calculator and Calendar as configured by the User Group administrator:
Additional details #
Because the pages are copied to a user's set of pages, once copied, they can be changed at any time. When a user is removed from a user group the associated pages won't be removed: they have become that user's pages. The system is smart enough, however, to detect when a user is added again to a group of which he was already part of and the pages are not added again.
If an administrator modifies page templates for a User group after users have already been added to the group, those changes will be used when new users are assigned to the user group. Since the pages are templates, however, the changes won't be applied to users that were already members of the user group.
Users can belong to many User Groups. If you have templates defined for a number of groups, this may result having many page templates copied to users' pages. To prevent this, you can combine pages from different user groups into a single page. This will be covered in the next section.
Page Composition Through Several User Groups #
Composing a user page by combining pages from different user groups #
While the functionality described so far is quite powerful, in some complex scenarios it might not be enough. This section describes how more even flexibility can be achieved by combining the pages from different user groups into a single user page when she belongs to more than one of them.
Let's expand our previous example by dividing the Students into First Year Students, Second Year Students, Third Year Students, International Students, Prospective Students, etc. For each of these types of students we want them to have a page with the Loan Calculator and Calendar, but depending on which type we also want other different portlets to be on that page too.
This can be achieved by a naming convention for the pages. If two or more pages of different user groups have the same name, they will be combined into a single page when they are copied to a user's personal pages set.
In the example above, a User was added to a Students group which had a page called You are a Student. If the administrator creates a page template with the same name (You are a Student) in the First Year Students group and puts in it an RSS portlet pointing to information interesting for them, that page would be combined with the You are a Student page that's in the Students group, and the resulting page would contain the portlets configured for both User Groups:
Page Combination Rules #
The following rules are used when composing a page by combining pages from different user groups:
- Whenever a page is added from a User Group when the user becomes a member if the user has a previous page with the same name in the same set (public or private) they are combined.
- If any of the pages has the name translated to several languages only the default language is considered in the comparison
- The portlets of the new page will be copied at the bottom of the equivalent columns of the existing page.
- If the existing and the new pages have different layout templates, the existing one is preserved.
- If the new layout template has portlets in columns that do not exist in the existing one those portlets will be automatically copied to the first column of the existing layout template.
As you can see, it is possible to have a very flexible configuration for the default pages of portal users. Furthermore, that configuration can be changed at any time using the UI administrators are used to and then assigning users to new user groups.
While these examples are somewhat simple, the system allows for as many user groups as desired. By using the convention of matching the page names it is possible to build any default page composition desired for your users.