Blogs

Blogs

New in Liferay 5.2: Support for many independent message boards, blogs, wiki, ... per community

As most readers will probably know, one of the most powerful characteristics of Liferay's portlets is the fact that when they are added to different communities or organizations (whenever I use the word community from now on it also applies to organizations) they act as completely independent portlets, each with it's own data. For example, if you have two communities, one called "Soccer lovers" and another one called "Soccer haters", which have the message boards portlet added to their pages, each of them will effectively have their own independent forum. As you can guess from this example that's very important because otherwise the results would be unpredictable. The following diagram shows how the data from each forum is stored separately in the database:



This is one of the reasons why many people use Liferay's tools instead of specific purpose tools, because that way a single installation can hold tens, hundreeths or even thousands of forums, blogs, wikis, etc. One per community of the system. But apparently many people thought that wasn't enough and they started asking for the ability to have several independent instances of those tools per community.

That's one of the things I love about Open Source, there is always people pushing you to go one step further. Not only that, but sometimes one community member not only asks for the functionality but steps ahead and offers to help. In this case, that community member was [url=http://www.liferay.com/web/jesperw/profile]Jesper[/url] and the people from Kanal5. Jesper discussed with us the best approach to implement this possibility and some time later provided a working implementation for it. From there on Brian and I worked on some improvements but most of the hard work has already done. Thanks a lot Jesper!

Back to the functionality, it works by allowing each community to have several scopes of data. 'scope' is just the term we've decided to use to mean a set of data (for example forum categories and threads) that is isolated from other data of the same portlet. Any community has a default scope (what Liferay already had in all versions prior to 5.1) and it's also possible to create [b]an additional scope per page[/b] (either public or private).

Let's use the message boards portlet again as an example to explain how to create an additional scope. When the portlet is added to any page of the "Soccer lovers" community it will use the default scope. If they add the portlet to a second page, it will show the same data as in the first page (see note 1) To make this portlet use a different data scope you have to follow this simple steps:

1) Go to the configuration of the portlet
2) Click the tab called scoping
3) Using the select box choose "Current page (forum)" and save
4) Go back and use the portlet to add any data that will now be specific to this page.


Repeat for as many pages as desired, with any portlet that supports scoping. All of Liferay's core portlets where it makes sense to use this feature have been modified to support it. Furthermore, it's been implemented in a way that it's quite easy to add support for it for custom portlets too (I can write another blog entry about how to do it if there is enough interest).

That's it, enjoy the feature and I hope you like it.


Note 1: We've decided to keep the previous behavior so that any portlet added uses the default scope of the community. This way if you don't need more than one scope per community (which we think is going to be the most common case) things just work as they've always worked. If you do need several scopes you just have to follow a few extra steps as outlined above.

Nice post! Thank you, Jorge!

Is this main usage of custom attributes on the scope of portlets?

Looking forward to seeing your suggestions on the usage of custom attributes for dynamic content model.
emoticon ...Is there anyone who hates soccer? how is that possible? XD jokes...

This is an awesome feature!!! thank you for this great news Jorge.

...and for those who hate soccer, I recommend you watch the FC Barcelona (Spanish League) and will change your mind, or it doesn't George?
Is there a possibility to have an aggregated portlet of all the independent ones.

In detail, if you have a calendar for a few communities, can you have an aggregated calendar with all events from the communities?
Jorge,
Great Post! I would be interested in seeing another blog about how to add this support to custom portlets.

Daniel,
This would be a cool portlet. An organizational calendar. Boss has a calendar, secretary has a calendar, worker has a calendar, and the group has an aggregated calendar that would show all the "Public" content from the individual calendars. Great idea.

Could apply to more than just calendars? What other types of portlets would benefit from this?
@Daniel: most of the included portlets do not do that although there are some exceptions such as the Blogs Aggregator and the Activities portlet. You can also create your own portlets that do the same thing for Calendar or any other portlet. An alternative would be to modify the out of the box portlets themselves. Although I would only do it that way if you plan to contribute it back, because otherwise you'll have to maintain it version after version.
Thanks Jorge,
Just read this amazing improvement and one idea came out in my mind.

As an example I will refer to the Wiki Portlets: We have a Wiki main portlet and a Wiki View Portlet. The Wiki view relates to node in the Wiki tree.

This idea could also be applied here in the sense of a Forum View that selects a concrete category. This way you can republish the forum category that you want whereever you want. You can separate Views making them look independent, but you can have also a global view with all the tree.

It could also be applied to Galleries and other tree based portlets.
@Iñaki: sounds good. Do you want to give it a try and contribute it back? emoticon
Nice Jorge. But I think I found a bug which caused by the implementation of this new feature. You might want to check that (incl possible solution):
http://issues.liferay.com/browse/LPS-2220
Hi Rob,

Yup, I was just looking at that issue. We'll try to solve it ASAP.

Thanks for reporting it!
Thanks, I don't think it's hard.
It would be great if the Directory portlet could have the same behaviour (directory content regarding the community), but harder to implement since it's a core portlet ?
Hi Nico,

You mean the Directory of users? That wouldn't make so much sense since that portlet looks for the users in the portal so it's not scoped even to the current community.

Maybe you are trying to use the portlet for a different scenario?
Hi Jorge,

yeah, right !
I would like to have a directory of users for a given community (for my need, a community = several users working on a given project).
I hacked the directory portlet by modifying the JSP and filtering by community (uggly hack I know..., so I didn't propose the modification to the Liferay community).

Maybe I will develop a specific portlet ?
Hi Nico,

Got it. I think it would probably be a good idea to create a new portlet for that, although reusing parts of Directory where it makes sense. Let me know if you'd like to contribute it afterwards.
Ok !
I'll let you know !

Regards,
Nico
WOW...! thx a lot... was searching such a long time for this facility!!
I have set up a page specific blog (in My Community/public) but if I use the Wiki display on teh Guest Public page I cannot select the nodes or see any content when not logged in (e.g. guest). If I am logged in as admin I can see the content. Guest has View permissions. What have I missed?
Thanks
Kathy
Hi Kathy,

Please use the forums to post questions. That way more people will read it.
no problem, already did that and it seems there is a bug that prevents using the wiki display to display wiki content from another community
http://issues.liferay.com/browse/LPS-2856
Is there a way to do the opposite of this and have 1 wiki that covers all of my communities instead?
Hi Josh,

The best way to achieve that is to have 1 community for the wiki and have all users access that one to access the shared info.
Hi Jorge,

I am using liferay first time. With tomcat I added a user with administrative priviledge through the account test. When I try to add a child page I am not able to see that. Can you help me on this?


Thanks
Somen (somenshaw@gmail.com)