问题
In Liferay 6.1 custom theme - How can I get Sites for a user that it is a member of in a theme?
I have seen how the dockbar Go to/My sites
gets generated via the Liferay UI taglib.
However, I want to get a list of user's sites and list them as part of super navigation bar separate from the dockbar options.
Is this possible and what is the API call to get the user's sites in a list?
Thanks in advance.
回答1:
From the user object you can retrieve the groups he belongs to:
$user.mySites
This returns a List<Group>
. Once you have the Group
you can easily build a URL to the public and private pages of this group:
<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>
来源:https://stackoverflow.com/questions/12469131/how-do-i-get-sites-of-which-the-user-is-a-member-in-liferay-theme