I am writing a Portlet, which will be placed on a given liferay site. Liferay can have multiple sites, which can be public or private.
How can I generate a link (in my portlet JSP) to root page of the site in which the portlet was placed? e.g. for the site mySite
I expect something like http://localhost:8080/web/mySite/
Those two are not what I need:
themeDisplay.getPortalURL() // "liferay portal web root", not site root
themeDisplay.getURLHome() // default site home, not necessarily my specific site
I hope the following meets your needs :
String portalPath = PortalUtil.getPortalURL(themeDisplay);
boolean isPrivateLayout = themeDisplay.getLayout().isPrivateLayout();
Group scopeGroup = themeDisplay.getScopeGroup();
String groupUrl = PortalUtil.getGroupFriendlyURL(scopeGroup,isPrivateLayout,themeDisplay);
String result = portalPath + groupUrl;
Best regards, Alain
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments