2012-02-03 51 views
0

即时通讯设法创建一个社区选择框,使访客能够跳转到打开Liferay社区。但它似乎只适用于经过身份验证的用户。那么,我如何能够向所有用户列出“开放”社区,包括注销用户?如何列出社区以在Liferay 6中“登录”出用户?

这里是我当前的代码

#set ($myPlaces = $user.getMyPlaces()) 
    #if($listTool.size($myPlaces) > 0) 

     <select id="communitySelector"> 

     #foreach ($myPlace IN $myPlaces) 
      #if ($myPlace.isCommunity()) 

       #set ($myPlaceURL = ${myPlace.getFriendlyURL()}) 
       ## Only link if theres pages 
       #if ($myPlace.hasPublicLayouts()) 
        ## Prefix web for 'public' 
        #set ($myPlaceURL = "${public_pages_url}${myPlaceURL}") 

        ## Select if current community 
        #set($commSelected = "") 
        #if($themeDisplay.getLayout().getGroup().getName() == $myPlace.getName()) 
         #set($commSelected = " selected='selected' ") 
        #end 
        <option $commSelected value="${portal_url}${myPlaceURL.toString()}">$myPlace.getName()</option> 


       #end 

      #end 
     #end 
      </select> 
    #end 
+0

所以我想通了MyPlaces中只填入登录用户:(。创建用户的唯一解决方案是将其分配给所有可用的社区,并尝试列出该用户ID的社区? – htmlr 2012-02-04 02:03:23

回答

1

在这里回答我自己的Liferay问题的悠久传统是为我想出了挂牌社区的所有用户,包括公共解决方案的代码片段/来宾注销用户

## Grab this service as MyPlaces only available to authenticated users 
    #set($groupLocalService = $serviceLocator.findService("com.liferay.portal.service.GroupLocalService")) 

    ## Get all Groups 
    #set($groupList = $groupLocalService.getGroups(-1, -1)) 

    ## Grab all groups that are Communities 
    #set($commList = []) 
    #foreach($group in $groupList) 

    #if($group.isCommunity()) 

     $commList.add($group) 
    #end 
    #end 

    #foreach($comm in $commList) 
    ## Exclude Control Panel which is also validated as Community in LR 
    #if($comm.getName()!="Control Panel") 
     #if($comm.hasPublicLayouts()) 
      <a href="$comm.getFriendlyURL()">$comm.getName()</a><br /> 
     #elseif($comm.hasPrivateLayouts() && $is_signed_in) 
      ## Community is private so only print this link if user authenticated 
      <a href="$comm.getFriendlyURL()">$comm.getName()</a><br /> 
     #end 
    #end 
    #end 

编辑 - 这里有一个类似的片断别人贴https://stackoverflow.com/a/8457759/417933

相关问题