2012-02-03 48 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

相關問題