Varun
Varun

Reputation: 5061

Liferay: Page to portlet mapping

I have a requirement in liferay portal to allow user to add some specific portlets on a particular page. Same can be done in 2 ways:

  1. This will require some custom code to be plugged in add panel code

  2. create a custom portlet which will be present on left hand side of page and allows portlet to be added and dragged on page.

  3. On add of portlet it checks if the page can have this portlet and accordingly remove it

The question I have is which of these 2 approaches shall be used, and how?

Note: I was unable to find much about this on google as well

Upvotes: 1

Views: 232

Answers (2)

Olaf Kock
Olaf Kock

Reputation: 48087

Based on your comment to Tomáš Piňos's answer, my suggestion would be to create a custom portlet that uses Liferay's API and enables you to do just this: On the page where it's available, use it to enable/disable the portlets you'd like to be there by use of Liferay's API. You'll find quite a lot of sample when you're looking for the old sevencogs example (that sadly does not compile any more, but in general the API has only changed marginally). The most up to date resources with further links to the ancient code are these 2 blog articles.

About your third option (as you ask in the comments): Yes, it's possible: You can override Liferay's Services as well as react to model changes. This means that you could add your own check on updates. However, I'd feel it inappropriate to offer the option to add any portlet only to prohibit it whenever a user indeed uses the offered option. That's why I didn't include this option in my initial answer.

Upvotes: 1

Tomas Pinos
Tomas Pinos

Reputation: 2862

I believe Liferay permission system is strong enough to express what you need.

The portlet list shown in "Add more portlets" menu can be customized through a Regular Role. See How to customize which portlets to show in “Add more portlets” menu for detailed info.

To restrict the options for a single page (or several pages), modify its permissions, so that only the new Regular Role is be able to update it.

Upvotes: 1

Related Questions