Thursday, October 3, 2019

Display all the sites a user can access

I've heard many people ask for a place to view all the sites they have access to.  Using the content search web part you can accomplish this and have a page that by using search, which returns unique results for each user based on their permissions, each user gets a unique list of the sites they can access that looks something like this:


The following steps describe how to create this:

Upload the template files and css
First, download the the code from the following in github:  https://github.com/sregan1/SharePoint-Office365/tree/master/Sites%20Directory

Open up SharePoint Designer and select on All Files in the left hand navigation.  Then go to /_catalogs/masterpage/Display Templates/Content Web Parts.  Copy Control_Sites_Directory.html and Item_Sites_Directory.html here.  Edit the url in these files (where it says "vivity.sharepoint.com") to your url.

Go to Site Assets, and create a Styles folder (if not there already), and copy SitesDirectory.css there.

Select the templates
First, add a content search web part to your page and edit it.  In the dropdowns, select the newly added Sites Directory for the Control and Item Sites Directory for the item.


Setup the web part query
edit it, hit the Change Query button, Switch to Advanced Mode and paste in the following "contentclass:STS_Site" into the Query text box


You might want to remove some sites/paths from the query as needed by using the Property filter (e.g. -Path:https://vivity.sharepoint.com/sites/sitenottoshow).  If you want to add subsites as well, make the query text (contentclass:STS_Site OR contentclass:STS_Web).

And that should be it!

NOTE:  If some sites aren't showing, just kickoff a re-index of the site in Site Settings  -> Search and offline availability...

References
The paging functionality was referenced from Sean McDonough's blog here:  https://sharepointinterface.com/category/sharepoint-2007/development/


7 comments:

tejaswini said...

What an extremely wonderful post this is. Genuinely, perhaps the best post I've at any point seen to find in as long as I can remember. Goodness, simply keep it up.360DigiTMG data scientist malaysia

360digitmgdelhi said...

I've been looking at a portion of your posts on this site, and I think this site is really enlightening! Keep setting it up.
artificial intelligence course in delhi

360DigiTMG said...

I see the best substance on your blog and I unbelievably love getting them.
training provider in malaysia

PMP Certification said...


This is actually the data I'm searching for, I was unable to have requested a less difficult perused with extraordinary tips this way... Much appreciated!
PMP Certification

dataanalyticscourse said...

I have a strategic I'm seconds ago chipping away at, and I have been at the post for such data
360DigiTMG data analytics course

360digitmg said...

I am overwhelmed by your post with such a nice topic. Usually I visit your blogs and get updated through the information you include but today’s blog would be the most appreciable. Well done!
business analytics course

nakshatra said...

This post is easy to peruse and acknowledge without forgetting about any subtleties. Extraordinary work!
difference between analysis and analytics