RE: Get site id or name in theme

Peter Hellstrand, modified 13 Years ago. Regular Member Posts: 166 Join Date: 11/30/11 Recent Posts
Hello

Is it possible to get the site id or name in theme.


If($site.getId == "the_site"){
    <a href="site url">link on visible on my site</a>
}

thumbnail
Harish Kumar, modified 13 Years ago. Expert Posts: 483 Join Date: 7/31/10 Recent Posts
Hi Peter,

site id is nothing but the group id in Liferay.

long id = themeDisplay.getLayout().getGroupId();


Regards
thumbnail
Avinash R, modified 12 Years ago. New Member Posts: 13 Join Date: 9/19/13 Recent Posts
how can i get the same in the custom portlet implementation?

EDIT: found it out

in portlet implementations use:

PortalUtil.getScopeGroupId(request);


to get the site id. Although this means that the staging and live sites will have different set of data.
thumbnail
Jignesh Vachhani, modified 13 Years ago. Liferay Master Posts: 803 Join Date: 3/10/08 Recent Posts
You can use $theme_display.getScopeGroupId() in your theme
Peter Hellstrand, modified 13 Years ago. Regular Member Posts: 166 Join Date: 11/30/11 Recent Posts
Thank you both
Nahuel Barrios, modified 12 Years ago. New Member Post: 1 Join Date: 8/8/13 Recent Posts
Hi, in our team we get it working (get the site name) by using:

[indent]#set($groupLocalService= $serviceLocator.findService("com.liferay.portal.service.GroupLocalService"))
<h1>$groupLocalService.getGroup($groupId).getName()</h1>[/indent]


Greetins!