Managing Content for Similar SharePoint Sites Reply

Mike BerrymanI have a client that has over 50 subsites of the root site in a SharePoint site collection that are all pretty much the same.  There’s a site for each county in the client’s state, each one with web parts to show some data from the root site that’s relevant to that specific county (contacts’ information, documents, that kind of thing).  Whenever they wanted to make a change to, say, the contacts web part for these county site, they had to modify over fifty copies of the same web part.  Tedious to say the least.  After a few rounds of making these kind of repetitious modifications it was decided that I would need to come up with a solution to make managing this stuff much easier.

So I did.

The first thing I did was just remove all the web parts that were pulling data from the parent site.  I replaced each one with a content editor web part that used an HTML file from the root site as its content.  This way I was able to move the markup being used by all 50+ of these county sites to just one location.  I used some Javascript and SharePoint REST API calls to get the data the client wanted to display in each site and mimicked the look & feel of the web parts they had be previously using.  Any changes to the script or HTML would apply to every one of the county sites since they were all using the same HTML file as the source for their respective content editor web parts.

“But wait!”, I hear you say, “Wouldn’t that mean every county site would end up fetching the same data?”.  Indeed it would, were it not for the 2nd trick here to make each instance of the Javascript “unique”.

In each county site I added a Javascript “settings” file that would set some global variables (sidenote: I did this by using Script Injection, which I wrote about in this blog post, except instead of adding the custom action to the site collection I added it to the specific site).  The common Javascript located in my root site and used by all 50+ subsites’ content editor web parts would use these global variables in order to fetch the correct data for the county site.  Of course all these sites’ “settings” would have to be manually set up, but it’s a monotonous task worth undertaking to make future maintenance 100 times easier.

In this way I was able to remove the headache of having to modify 50+ web parts across 50+ sites and instead only have to apply changes to one central location for it be reflected across all the subsites.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s