Reputation: 21
I need help in printing private and public sites of which the user is a member.
By resuing the code from the post (How do I get Sites of which the user is a member in Liferay theme?) I am able to get the sites, but it gives users' private and public pages too.
How to avoid printing user's private and public pages, since I need only Communities or rather Sites.
<ul>
#foreach($site in $user.mySites)
#if ($site.hasPrivateLayouts())
<li><a href="/group${site.friendlyURL}">$site.descriptiveName</a></li>
#end
#if ($site.hasPublicLayouts())
<li><a href="/web${site.friendlyURL}">$site.descriptiveName</a></li>
#end
#end
</ul>
Environment: Liferay 6.1
Thanks
Upvotes: 1
Views: 1150
Reputation: 11698
I think you can use the same code with some changes:
<ul>
#foreach($site in $user.mySites)
<!-- if it is NOT a user's public or private site only then print it -->
#if(!$site.isUserPersonalSite())
#if ($site.hasPrivateLayouts())
<li><a href="/group${site.friendlyURL}">$site.descriptiveName</a></li>
#end
#if ($site.hasPublicLayouts())
<li><a href="/web${site.friendlyURL}">$site.descriptiveName</a></li>
#end
#end
#end
</ul>
Note the if(!$site.isUserPersonalSite())
code, if the site is a user's public or private site (i.e. containing user's public & private pages) then don't print anything.
Upvotes: 1
Reputation: 151
Update the following properties in your portal-ext.properties
in liferay root
# Deactivate Personal Community with *private* pages:
layout.user.private.layouts.enabled=false
# Deactivate Personal Community with *public* pages:
layout.user.public.layouts.enabled=false
Upvotes: 0
Reputation: 147
I think instead of using the mysites section for user you should use the user services and group service to fetch the user groups.
#set($userId = $getterUtil.getLong($request.remote-user))
#set($userLocalService = $serviceLocator.findService("com.liferay.portal.service.UserLocalService"))
#set($user = $userLocalService.getUserById($userId))
#set($groupLocalService=$serviceLocator.findService("com.liferay.portal.service.GroupLocalService"))
#set($userGroup = $groupLocalService.getUserGroup($companyId,$getterUtil.getLong($userId)))
$userGroup
Upvotes: 1