Reputation: 5019
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
Upvotes: 2
Views: 1960
Reputation: 673
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
Upvotes: 4
Reputation: 4210
You can make use of themeDisplay.getLayout().getRegularURL(request)
or themeDisplay.getScopeGroup().getPathFriendlyURL(false,themeDisplay)
HTH
Upvotes: 1