Foren

How to show portlet topper for admin users only

Marc Howard, geändert vor 9 Jahren.

How to show portlet topper for admin users only

New Member Beiträge: 12 Beitrittsdatum: 22.05.14 Neueste Beiträge
The portlet toppers currently display for guests and admin users. I only want these to display if an admin user is logged in, how can i do this?
thumbnail
David H Nebinger, geändert vor 9 Jahren.

RE: How to show portlet topper for admin users only

Liferay Legend Beiträge: 14919 Beitrittsdatum: 02.09.06 Neueste Beiträge
Usually you'll disable the borders all together in the look and feel page.
thumbnail
Andew Jardine, geändert vor 9 Jahren.

RE: How to show portlet topper for admin users only

Liferay Legend Beiträge: 2416 Beitrittsdatum: 22.12.10 Neueste Beiträge
As David said, usually you disable them altogether, but if you REALLY want to do it for just admins, you can try updating the portlet.vm file from your theme and adding conditional logic for the user. You can reference the User object using $user velocity variable. My guess is the simplest way to do it would be to use the service locator to load either the UserLocalSeviceUtil or the RoleLocalServiceUtil class and then use those utils to check whether or not the user has the role required to render the html for the topper.
thumbnail
Suraj Bihari, geändert vor 9 Jahren.

RE: How to show portlet topper for admin users only (Antwort)

Junior Member Beiträge: 44 Beitrittsdatum: 20.12.13 Neueste Beiträge
Andew Jardine:
You can reference the User object using $user velocity variable.


Instead of using the $user variable in Velocity, you can also access the $permissionChecker.

$permissionChecker.isCompanyAdmin($themeDisplay.getCompanyId())


See the following thread for more info here.

HTH!
Suraj