How do I get Sites of which the user is a member in Liferay theme?

邮差的信 提交于 2019-12-12 09:16:18

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!