How to Create a Dynamic Page for Terms of Use

Introduction #

Liferay has a feature that allows forcing all users to accept a Terms of Use text before using the portal for the first time. A default text is included with the portal but in most installations using this feature this text will need to be customized. The simpler way to change that text is to modify the following JSP:


That is probably all you need for simple sites, but for more complex ones it's useful to find a solution that allows changing the text of the Terms of Use dynamically. For example, by using a Web Content article (formerly Journal article). This solution is very useful when:

  • The terms of use change frequently
  • There is a need to have its text translated to several languages
  • You want to use the established mechanics of Liferay to modify this text instead of having to get administrative access to change an already deployed jsp.

The following section explains how to achieve this.

Using a Web Content Article to manage the Terms of Use #

Using a Web Content Article to change the text of the Terms of Use varies depending on the version you use.

Liferay 5.2.x#

There are now properties you can use to specify an article to use and no code need by modified as the logic has been integrated into the portal. Use these values in your

    # Specify the articleId of a Journal Article to use for the terms of use.

    # Specify the groupId of the group to which the Journal Article specified by
    # "" belongs.


The groupId should be the identifier of the community where the article was created. Again, if you don't want to hardcode this id use the GroupService to obtain it dynamically from the community name. You can locate the GroupId for the Edit view on the Communities portlet, or from the Edit view of a particular Organization.

Prior to 5.2#

Note: This does not apply to all versions prior to 5.2 - see below if you are about to configure an older version - This article just mentioned "older" and "more recent" versions, I don't know when the changes occurred (somebody who knows should add this information)

You'll have to modify the following JSP:


You can directly specify the articleId and groupId to the tag:

<liferay-ui:journal-article articleId="TERMS-OF-USE" groupId="<%= groupId %>" />

Older versions of Liferay#

You'll have to modify the following JSP:


Remove all the text inside (but leave the form!) and copy it to a Journal Article of your choice. When creating the article give it an id that is easy to remember (if your portal is configured to allow for manual ids), such as TERMS-OF-USE.

Once the article is created you'll have to find it's resource primary key. As of now the UI doesn't show it, so you'll have to go to the database. If you gave the article an easy to remember id it'll be easier to find. Once you have the primary key add the following to the JSP above instead of the terms of text:

 <liferay-ui:journal-article articleResourcePrimKey="<%= articleResourcePrimKey %>" />

If you don't want to hardcode the primary key of the article, you can obtain it using the Journal services from the groupId and the article id, for example:

<% JournalArticle article = JournalArticleLocalServiceUtil.getArticle(groupId, "TERMS-OF-USE");
long articleResourcePrimKey = article.getResourcePrimKey(); %>
<liferay-ui:journal-article articleResourcePrimKey="<%= articleResourcePrimKey %>" />
0 Attachments
Average (0 Votes)
The average rating is 0.0 stars out of 5.
Threaded Replies Author Date
Now, that's handy! Joshua Asbury September 16, 2008 5:00 AM
This is very useful for dynamic web sites! Jonas Yuan September 16, 2008 9:18 AM
Great feature! Now all administrators on our... Markus Lindgren June 3, 2009 5:21 AM
I can't get this to work in 5.2.1. I have a... Peter B West August 28, 2009 4:06 AM
This feature works only if you have same terms... Fabio F October 16, 2009 4:41 AM
so ... how can I set different "terms of use"... Armando Ota November 26, 2009 6:39 AM
I believe instance-specific settings are still... Ed Holderman August 23, 2011 9:43 AM

Now, that's handy!
Posted on 9/16/08 5:00 AM.
This is very useful for dynamic web sites!
Posted on 9/16/08 9:18 AM.
Great feature!
Now all administrators on our project can manage the Terms of use instead of the developers.
Posted on 6/3/09 5:21 AM.
I can't get this to work in 5.2.1.

I have a Web Content document. I Assume that the JournalArticle table covers what is now known as Web Content. I'm assuming that is groupId and is articleId from the JournalArticle table. Is this correct? If so, I can't see the article. The item above indicates that the correct field is resourcePrimKey, but that doesn't work either. Has anyone got this to work?
Posted on 8/28/09 4:06 AM.
This feature works only if you have same terms of use for all portal instances.
I need to use a customized terms of use for every portal instance and there insn't an instance property to do this. Only a global terms of use is allowed, isn't it?

Posted on 10/16/09 4:41 AM.
so ... how can I set different "terms of use" for different organizations ???
Posted on 11/26/09 6:39 AM.
I believe instance-specific settings are still not possible out of the box: . Is everyone just implementing their own T&C logic to pull up the instance, community, or organization-specific T&C article using a more dynamic way?
Posted on 8/23/11 9:43 AM in reply to Armando Ota.