开发者

Writing Portlets for Liferay CMS/Portal

开发者 https://www.devze.com 2023-01-04 23:08 出处:网络
I am new to portle开发者_如何学Gots and have a question about how they work in CMS portals ( we are evaluating Liferay as a CMS ).

I am new to portle开发者_如何学Gots and have a question about how they work in CMS portals ( we are evaluating Liferay as a CMS ).

Let's say, for example, I would like to create a portlet to display all the books required for a particular course. You don't have to be logged in to see this, it will appear on public website.

In the CMS, I will create two pages for ENGL-100 and HIST-300.

I want to add the same portlet on each page. I expect to deploy the portlet as a war file.

How will I tell the portlet on each page which course to look up? Don't tell me I have to change the portlet.xml file for each subject. Does a portlet have any access to URL parameters?


Portlets should not rely on URL parameters directly - for this exact reason - you might have multiple instances on the same page, and don't want them to collide (since they'll all see the params during Render, though only one will get Action)

In Liferay, you can just drop 2 portlets, and if you use Preferences through an EDIT or Liferay Config view, the prefs will be scoped separately to render initial state. The container will handle keeping the 2 portlets straight.


Yes, portlets can process URL parameters. That's the way you'd go to implement what you want. Depending on the page you are visiting, you just pass the course subject as a URL parameter and let the portlet process it for you. Of course you have to go to the database to look for the right course, etc to return the proper data.

0

精彩评论

暂无评论...
验证码 换一张
取 消