Documentation
Liferay provides a rich store of resources and knowledge to help our community better use and work with our technology.
Understanding Liferay's common configuration options
Just like siblings have common features inherited from their parents, applications that ship with Liferay also share common features. These are centered around scoping, sharing, permissions, and archives. So before we get into the nitty gritty of the applications themselves, it's best to cover these common features first, starting with the concept of scope.
Scope
As we learned earlier, roles can be scoped by the portal, by a site, or by an organization. A role only takes effect within its scope. For example, a Message Boards Administrator role with complete access to the Message Boards portlet has different permissions based on the role's scope. If it's a portal role, members have permission to administer message boards across the entire portal. If it's a site role, members only have permission to administer message boards within the site where they've been assigned the role. For organizations with sites, site roles are automatically assigned to organization members based on the organization roles they have. So for an organization-scoped Message Boards administrator role, members only have permission to administer message boards within the site of the organization that assigned the role to them.
We also use the word scope to refer to the data set of a portlet. By default, when a portlet is added to a page in a site, it is scoped for that site. This means that its data belongs to that site. If the portlet is added to a page in a different site, it employs a completely different data set. This enables you to place a Message Boards portlet in one site with one set of categories and threads, and place another Message Boards portlet in different site with a different set of categories and threads.
Scoping by site means that you can only have one Message Boards portlet per site. If you add one Message Boards portlet to a page in a site and add another Message Boards portlet to a different page in the same site, the second Message Boards portlet contains exactly the same data as the first. This is because, by default, the Message Boards portlet is scoped by site. Most of Liferay's other portlets also default to being scoped by site.
To avoid this limitation, many Liferay portlets can be scoped by page. In this case, the data sets of page-scoped portlets serve a single page, not an entire site. If you set the scope of a portlet to page instead of site, you can add any number of these portlets to different pages, and then they have different sets of data. This allows you to have more than one message board per site if you wish. Most portlets, however, default to the "native" configuration, and have their scopes set to the site where they are placed.
Unless otherwise noted, all the portlets in this chapter support scoping by portal (global), site (default), or page (select layout → current page). This grants you some flexibility in how you want to set up your portal. You can configure the scope of a portlet with just a few simple steps.
Click the Menu icon in the portlet window (the wrench).
Select Configuration.
Select the Scope tab.
Use the drop-down menu to set the scope.
Click Save.
Figure 4.1: Changing the scope of a portlet
That's all it takes to change the scope for a particular portlet instance. By setting the scope to Current Page, you can add as many of these portlets to a site as you want, provided they are all added to separate pages.
Another useful feature of Liferay's portlets is Archived Setups.
Archived Setups
Once you've configured a portlet, Archived Setups enables you to save those settings in an "archive". If someone goes in and changes the settings of a particular portlet, it then becomes easy to revert those changes back to the original, archived configuration.
To create an archived setup, click the Configuration option from the menu in the portlet's title bar. If the current settings of the portlet you're configuring are the ones you want to archive, click the Archive/Restore Setup link. If not, change and save the settings until you have the portlet configured the way you want it, and then click the Archive/Restore Setup link.
There is only one field to fill out. Enter a name for your archive and click Save. You should now see your archive in the list. If you ever need to revert the portlet to these archived settings, you can click Actions → Restore next to the archived setup you want to restore.
Unless otherwise noted, all of the portlets in this chapter support this feature. This is particularly useful for portlets that have a lot of configuration options, such as the Message Boards portlet.
Next, we'll see how permissions apply to Liferay portlets in general.
Permissions
All of Liferay's portlets support Liferay's robust, fine-grained permissions system. Some higher level permissions can be configured in the permissions tab of the portlet configuration dialog box. You can grant roles permission to add the portlet to a page, configure the portlet, or view the portlet. To set these permissions, go to the Configuration menu and click on Permissions. This shows you a table of roles defined in the portal. Use the check boxes to grant certain permissions to different roles. Click Submit after you have made your selections.
Beyond this, specific permissions are generally defined for specific applications. For example, the message boards portlet contains a Ban User permission. This makes no sense in the context of another portlet, say, the blogs portlet. We'll go over permissions for specific applications in the sections for those applications. For now, let's move on to sharing applications.
Sharing
The web was once thought of as a number of islands of applications in a vast universe of "cyberspace." Many web sites attempted to make their island the biggest. Some succeeded to a large extent and some failed. More recently, the concept of the web as an application itself has taken hold, and so widgets have become very popular nowadays. This concept is part of the "Web 2.0" concept and is very much enabled by widgets. What is a widget? A widget is a small piece of code which provides a piece of functionality, can be included on any web site, but does not necessarily have to be hosted by that web site. If you have ever embedded a YouTube video on your own web site so that users could watch a video without actually having to visit http://youtube.com, then you've already used a widget.
Liferay supports serving its portlets as widgets. You can embed a particular instance of a portlet running on your site into another site, such as Facebook. This opens up a whole new avenue of exposure to your web site that you would not have had otherwise. In fact, this is how all those Facebook games work.
Figure 4.x: Sharing Tab of the Portlet Configuration Dialog Box
To share one of your portlets as a widget, open the Configuration dialog box from the portlet's title bar and select the Sharing tab. There are five subtabs under sharing: Any Web Site, Facebook, Google Gadget, Netvibes, and Friends.
Any Web Site
Copy and paste the provided snippet of JavaScript code into the web site to which you want to add the portlet as a widget. That's all you need to do. When a user loads the page on the other web site, the code will pull the relevant portlet from your site and display it.
You can add any Liferay portlet as an application on Facebook. To do this, you must first get a developer key. A link for doing this is provided to you in the Facebook tab. You'll have to create the application on Facebook and get the key and canvas page URL from Facebook. Once you've done this, you can copy and paste their values into the Facebook tab. Your portlet will now be available on Facebook as a Facebook application.
Figure 4.2: Liferay's Forums on Facebook
Incidentally, this makes Liferay a fantastic platform upon which to build applications for Facebook. See the Liferay Developer's Guide or Liferay in Action for more details.
OpenSocial Gadget
OpenSocial comprises a container and a set of APIs for social networking and other web applications. iGoogle is a service provided by Google that lets users create a customizable page and add Gadgets to that page. Liferay can serve up portlets to be used as Open Social Gadgets on iGoogle or other OpenSocial-compatible pages.
To serve a Liferay portlet on iGoogle, check the box labeled Allow users to add [portlet-name] to iGoogle. Then copy and paste the URL provided into Google's Add a feed or gadget feature on the iGoogle configuration page. Your Liferay portal instance will serve that portlet directly onto your iGoogle page. The URL provided is unique to the specific instance of the portlet, so you could serve multiple instances of the same portlet as different Google Gadgets.
You could use this feature to allow users to view what's happening on your portal at a glance, using asset publishers or custom RSS feeds. You could also use Liferay's API to build your own portlet and provide the URL for users to place on their iGoogle pages.
Netvibes
Netvibes offers a similar service to iGoogle--users can log in, create their own personal portal, called a dashboard, and add customizable widgets to the dashboard that they create. To set up Netvibes support for a particular portlet, check the Allow users to add [portlet-name] to Netvibes pages box. You can then use the provided URL to create a custom Netvibes widget based on the instance of the portlet that you're using.
Friends
The final sub-tab of the Sharing tab is called Friends. This tab has a single check box that allows you to give your friends permission to add the application as a widget to another web site. This could be particularly useful for your blog or calendar if you wish to share them.
Now that we've seen all the common options available in Liferay's portlet applications, we can move on to specific applications, starting with blogs.