BigT
BigT

Reputation: 269

Current site URL in Liferay 6.2

I cannot figure out how to get URL of current site in Liferay. For example if i have created four sites - site1, site2, site3, site4. URL of this sites will be:

http://localhost:8080/web/site1/
http://localhost:8080/web/site2/
http://localhost:8080/web/site3/
http://localhost:8080/web/site4/

But how can i get this URLs from velocity (in theme)? I tried few options:

$themeDisplay.getPathFriendlyURLPublic() - /web
$themeDisplay.getPortalURL()             - http://localhost:8080
$themeDisplay.getURLHome()               - http://localhost:8080/web/guest
$themeDisplay.getURLCurrent()            - /web/site1/home

I need to get just http://localhost:8080/web/actualsite/.

Upvotes: 2

Views: 18881

Answers (2)

Tejas Kanani
Tejas Kanani

Reputation: 133

Try this in your theme vm. This should give you current complete url.

$portalUtil.getCurrentCompleteURL($request)

Output : http://localhost:8080/web/site4/home

Upvotes: 0

BigT
BigT

Reputation: 269

All right, after few hours of trying I find solution:

To get current site url, you need to use:

$layout.getGroup().friendlyURL in velocity.

This expression returns '/site-name' format.

Upvotes: 4

Related Questions