How many ways are there to find community id in liferay

thumbnail
guru murthy, modified 14 Years ago. Regular Member Posts: 208 Join Date: 8/12/11 Recent Posts
Hello all,

I want to know how to find community id . How many ways are there .
Please send the details

Thanks & regards
G.murthy
thumbnail
Mani kandan, modified 14 Years ago. Expert Posts: 492 Join Date: 9/15/10 Recent Posts
You can get like,


ThemeDisplay themeDisplay= (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
long portletGroupId= themeDisplay.getPortletGroupdId();


Community Id with name,


User user = themeDisplay.getUser();
Layout layout = themeDisplay.getLayout();
Group group = GroupLocalServiceUtil.getGroup( layout.getGroupId() );
String groupname = "";
if( group.isUser() ) groupname = user.getFullName();
if( group.isCommunity() ) groupname = group.getName();


And without themeDisplay object,

long groupId = GroupLocalServiceUtil.getGroup(communityObj.getCompanyId(), "Guest").getGroupId();


Hope it will help you
thumbnail
Hajri Mohamed, modified 14 Years ago. Junior Member Posts: 71 Join Date: 3/2/11 Recent Posts
cou can get community id too by simply using long communityId =
PortalUtil.getScopeGroupId(request)

regards
thumbnail
guru murthy, modified 14 Years ago. Regular Member Posts: 208 Join Date: 8/12/11 Recent Posts
Hey
Thanks to all who gave reply

Regards,
G.murthy
thumbnail
Jay Patel, modified 14 Years ago. Regular Member Posts: 118 Join Date: 2/24/10 Recent Posts
One more, if you have reference to themeDisplay:

themeDisplay.getScopeGroupId()

Regards,
Jay.