1

How would I create a search webpart (search results?) that would display all the Team sites I am a member off? Trying to create a 'My Dashboard' landing page for all users of the sharepoint service.

6
  • 1
    Member as in contribute/edit permissions? While all the search results are already security trimmed (read permissions and above), you could create a query to list all sites or site collections that are based on the teamsite template. Commented May 19, 2016 at 7:27
  • Are you allow to use custom coding or just ootb coding ? Commented May 19, 2016 at 7:31
  • You can refer to this blog which explains how search is used to find access of current member ilikesharepoint.de/2012/11/… Commented May 19, 2016 at 7:35
  • @MonicaJagani that links shows only how to get sites the user is allowed to see, not sites where user is a member Commented May 19, 2016 at 8:38
  • To add to @Christoffer's answer. From that raw list you could then (while being a quite hefty operation) make a request to each of the sites with e.g. REST to check users permission on that site and based on that trim what you do render to the user Commented May 19, 2016 at 8:40

1 Answer 1

1

You can use this search to find all the entries in the sites membership lists for the the current user

MemberOWSUSER:{User.Name}

Then create a custom Search Display template that only displays the site title, and the site url (trimmed from the item url)

<html xmlns:mso="urn:schemas-microsoft-com:office:office" xmlns:msdt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"> 
<head>
<title>Member of</title>

<!--[if gte mso 9]><xml>
<mso:CustomDocumentProperties>
<mso:TemplateHidden msdt:dt="string">0</mso:TemplateHidden>
<mso:MasterPageDescription msdt:dt="string">Displays sites that the current user is a member of</mso:MasterPageDescription>
<mso:ContentTypeId msdt:dt="string">0x0101002039C03B61C64EC4A04F5361F385106603</mso:ContentTypeId>
<mso:TargetControlType msdt:dt="string">;#SearchResults;#</mso:TargetControlType>
<mso:HtmlDesignAssociated msdt:dt="string">1</mso:HtmlDesignAssociated>
<mso:ManagedPropertyMapping msdt:dt="string">'SiteTitle':'SiteTitle','Path':'Path'</mso:ManagedPropertyMapping>
<mso:HtmlDesignConversionSucceeded msdt:dt="string">True</mso:HtmlDesignConversionSucceeded>
<mso:HtmlDesignStatusAndPreview msdt:dt="string">http://uat.groupgovernance.cimic.com.au/sites/uat-mf/_catalogs/masterpage/Display%20Templates/Search/iPKL_CoP_Item_MemberOf.html, Conversion successful.</mso:HtmlDesignStatusAndPreview>
</mso:CustomDocumentProperties>
</xml><![endif]-->
</head>
<body>
    <div id="Item_Default">
<!--#_ 
        if(!$isNull(ctx.CurrentItem) && !$isNull(ctx.ClientControl)){

            var title = ctx.CurrentItem.SiteTitle;
            var url = ctx.CurrentItem.Path.substring(0, ctx.CurrentItem.Path.indexOf('/Lists/Members/DispForm.aspx?ID='));

            var imageUrl = url + '/SiteAssets/community-image.png';
_#-->
        <div>
            <a href="_#= url =#_">
                <img src="_#= imageUrl =#_" onerror="this.style.display='none';" />
                <br/>
                _#= $htmlEncode(title) =#_
            </a>
        </div>
<!--#_ 
        } 
_#-->
    </div>
</body>
</html>
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.