Tribune

Home » Liferay Portal » English » 3. Development

Vista Combinata Vista Piatta Vista ad Albero
Discussioni [ Precedente | Successivo ]
toggle
Lokesh Kumar N
Need to get information of the Community in a portlet
5 marzo 2013 1.34
Risposta

Lokesh Kumar N

Punteggio: New Member

Messaggi: 1

Data di Iscrizione: 14 agosto 2012

Messaggi recenti

Hi,

Let's say I have added a portlet inside a community. From the portlet I need the information of the community such as the community name, community owner etc...

How to get these community information from the portlet. Any suggestions here would be helpful

Thanks,
Lokesh
Juhi Kumari
RE: Need to get information of the Community in a portlet
5 marzo 2013 4.13
Risposta

Juhi Kumari

Punteggio: Expert

Messaggi: 347

Data di Iscrizione: 12 dicembre 2011

Messaggi recenti

Hi,
You can get information of a community like this
 1List<Group> groups = GroupLocalServiceUtil.getGroups(QueryUtil.ALL_POS,QueryUtil.ALL_POS);
 2String name;
 3long userId;
 4User user;
 5for(Group group : groups){
 6        if(group.isCommunity()){
 7            name = group.getName();
 8            userId = group.getCreatorUserId();
 9            user = UserLocalServiceUtil.getUser(userId);
10            System.out.println("Community Name >>> "+name+" Owner Name >>> "+user.getFullName());
11        }
12    }


Regards
Juhi
Felix J Christy
RE: Need to get information of the Community in a portlet
5 marzo 2013 6.19
Risposta

Felix J Christy

Punteggio: Regular Member

Messaggi: 111

Data di Iscrizione: 25 agosto 2009

Messaggi recenti

Hi,

To access the current community in which the portlet is deployed, you can call the PortalUtil.getScopeGroupId(portletRequest) method. After getting the groupId, just get the group name using

GroupLocalServiceUtil.getGroup(long groupId);.

Once you get the Group object, just take the name and owner info.


Thanks,
Felix