留言板

Detecting Control Panel

Michael Illgner,修改在14 年前。

Detecting Control Panel

Junior Member 帖子: 33 加入日期: 09-6-30 最近的帖子
Hi
I have a portlet which may be instantiated on any page, but should also work in the control panel with a slightly different behavior ?

How can a portlet detect if its instantiated in the control panel ? Is there special flag in the ThemeDisplay or something like that ?

Regards
thumbnail
Amos Fong,修改在14 年前。

RE: Detecting Control Panel

Liferay Legend 帖子: 2047 加入日期: 08-10-7 最近的帖子
Hi Michael,

This is how it's done in ServicePreAction.java:

if (group.getName().equals(GroupConstants.CONTROL_PANEL)) {


You should be able to get the current group from themeDisplay.getScopeGroup()
Michael Illgner,修改在14 年前。

RE: Detecting Control Panel

Junior Member 帖子: 33 加入日期: 09-6-30 最近的帖子
Thanks,
This seems to work

But you have to retrieve the group from the layout, it is not the scopegroup.
if (layout.getGroup().getName().equals(GroupConstants.CONTROL_PANEL)) {
thumbnail
Amos Fong,修改在14 年前。

RE: Detecting Control Panel

Liferay Legend 帖子: 2047 加入日期: 08-10-7 最近的帖子
oh right you are correct, my mistake.

Scope group would refer to the community/organization you are administering from the control panel.
Guillaume Kuhmel,修改在12 年前。

RE: Detecting Control Panel

New Member 帖子: 11 加入日期: 12-3-6 最近的帖子
Hello,

Thanks for the info but how to retrieve the layout object inside a PortletAction object ?
Thanks
thumbnail
Pankaj Kathiriya,修改在12 年前。

RE: Detecting Control Panel

Liferay Master 帖子: 722 加入日期: 10-8-5 最近的帖子
Hi Guillaume Kuhmel,

You can use themeDisplay objec to get current layout you want.


HTH,
Regards,
Pankaj