Turn Liferay Into A Blog Service
Part 1.1 - User Account Mechanism #
I've been playing around with Liferay portal version 5.0.1 and have found some new features that make it easy to create a community driven website. When I hear good news, I just wanna share it, so here it is. Enjoy!
Part 1.1 is meant for beginner Liferayers to get familiar with some of the cool out of the box settings Liferay portal has that may help you in other projects. The footnotes provide details for more curious folks! At the end of Part 1.1, you will have configured Liferay so that strangers can sign up for an account on your website. In this section, we won't do ANY programming.
- Download Liferay + Tomcat bundle: http://downloads.sourceforge.net/lportal/liferay-portal-tomcat-5.5-5.0.1.zip
- Unzip the bundle to a directory of your choice.
- Let's browse to where you unzipped the Liferay Tomcat bundle; I will refer to this location as $TOMCAT_HOME. Go to $TOMCAT_HOME\bin and double click on startup.bat.
- Open a web browser and browse to http://localhost:8080
If you are having trouble with installation, refer to: http://www.liferay.com/c/portal/flash?movie=http://docs.liferay.com/4.4/videos/1001.swf
Default Account Creation#
At the upper right hand corner of the screen, you should see a dock menu. Hovering over it will produce a Sign In button.
- Click the Sign In button.
- Click on Create Account. Notice the different fields on the registration screen.
I've indicated the required fields (1): First Name Last Name Screen Name Email
- Fill in the required fields and click Save.
- You get redirected to the Login screen where it will also mention an autogenerated password.
- You finally land on a page with a bunch of default portlets. This is called a user's personal community or "My Community" (2).
Now you know the default account creation process. Let's modify some of this process by changing portal-ext.properties (3). Remember, no coding during in this section!
Custom Account Creation#
- Browse to $TOMCAT_HOME\webapps\WEB-INF\classes\. If it doesn't exist, create a file called portal-ext.properties. - Inside portal-ext.properties append the following and save:
admin.default.role.names=Power User\nUser field.enable.com.liferay.portal.model.Contact.male=false field.enable.com.liferay.portal.model.Contact.birthday=false field.enable.com.liferay.portal.model.Organization.status=false captcha.max.challenges=-1 terms.of.use.required=false auth.forward.by.last.path=false
- Restart Tomcat (4) and go through the Account Creation process again. Did you see the differences?
You've set up a website that will allow strangers to register for accounts and get their own set of personal web pages. You also know how to utilize the portal properties to customize Liferay to behave differently than the default. You should try exploring other portal settings (5). Stay tuned for the next Part in this series, which will cover customizing a user's personal web page.
(1) user account creation required fields
By default, Liferay requires at the very minimum a first and last name, screen name, and email address to create new user account.
(2) My Community:
A personal community is simply a special set or group of web pages for a specific user. Does every user get a personal community? No. Only user's with the Power User role get their own "My Community". By default, newly created users get the Power User and User role as specified in this portal.property setting:
All of Liferay's portal specific settings are stored in a file called portal.properties. So naturally, we'd want to modify portal.properties if we want to change any settings right? Wrong. Liferay was created in a way so that folks like you and me could modify ANYTHING, but the best way was to create an Extension environment where we make our changes. If we modify the source code directly, it will make it difficult to do upgrades in the future. What's the Extension equivalent of portal.properties? It's portal-ext.properties.
(4) Modifying portal-ext.properties:
You must restart the server in order for your modifications to take affect. Also, your modifications don't change old data; they only affect new data. This means that if you changed the portal's settings so that new users get the 'Power User' and 'User' role, the setting will not affect users who were created prior to your modification.
(5) Properties explained:
field.enable.com.liferay.portal.model.Contact.male=false field.enable.com.liferay.portal.model.Contact.birthday=false captcha.max.challenges=-1 terms.of.use.required=false
Since we want all users to receive personal communities we want to make sure to include this setting:
The property "admin.default.role.names" is also available via Enterprise Admin -> Settings -> Default User Associations so you can modify this setting in real time through the GUI.
We can ensure that a user always get forwarded to their peronal community's web pages when they login with this:
You can download Liferay portal 5.0.1 source code to see more details for these settings: http://downloads.sourceforge.net/lportal/liferay-portal-src-5.0.1.zip Just unzip and browse to $SOURCE_HOME/portal-impl/src/portal.properties