prevent duplicate site / page / layouts / templates / webparts, possible - sharepoint-2010

We have a sharepoint environment with many sites (and sometimes many site collections). Each site (or site collection) has the same default page with some custom webparts that use sitecolumn values (for example a projectcode or clientcode) to show information from external systems. (for each project we have to create a separate site (or site collection) because of other reasons)
What is the best approach to minimize duplication? The dynamic parts of the page are stored in site columns. When we add a new webpart, ideally the default page every site/page should show the new webpart without spreading the update to the individual pages
Thanks

One approach you may want to take is to use the web part as a wrapper for a user control. The user control does the heavy lifting on the site. Once the web part is included on your pages, the user control should be able to tell which site it is being executed on and pull the necessary dynamic data from your site columns.
When you need to make updates, you update the user control and then redeploy the solution package to the farm. Each site will pick up the change as soon as the solution is deployed.
Here is a little information about this approach:
http://msdn.microsoft.com/en-us/library/ff649867.aspx.
The above article relates to WSS 3.0, but that should give you a starting point.
An approach you may want to look at for SharePoint 2010 is a visual web part. More info can be found here: http://msdn.microsoft.com/en-us/library/ff597539.aspx.

Related

Sharepoint 2010 Break permission inheritance

I need to create a workflow that would break permission inheritance in a sharepoint subsite.
I am building a sharepoint 2010 site that is highly modular and can expand based on clients needs. The project requirement is that the client must be able to expand the website and add subsites from templates with as little interaction as possible. To this end I have created a list and attached a workflow to this list that creates a new website based on the information supplied in the list fields. The workflow I am using is a solution I found online http://www.ilovesharepoint.com/2011/02/create-site-action-sharepoint-designer.html
After the website is created I need to create security groups (another workflow I found online helps with this).
The problem is that the subsite must inherit security groups from the parent site and then I need to add new ones. In order to do this I need to break inheritance from the parent site and than I can create new groups. Currently my client has to do this manually - very bad thing. So I need create a workflow that would do just that.
The problem is that I am completely clueless as to how to go about doing this.
Ideally, I would like to create some sort of workflow action that would take a site url as input and then break permission. From what I've been able to find I need to use BreakRoleInheritance function to do that. but how do I create a workflow that takes input and how do i convert the string input into an actual site?
Like I said, I don't know anything about coding for sharepoint so please be as specific as possible.
Thank you very much.
P.S. maybe I am mistaken and i don't need to break inheritance to create additional security groups that would work only for a given subsite. If so, please tell me how to do this without breaking inheritance.

Programmatically accessing a Sharepoint list at runtime (without creating a service reference at design time)

I'm creating an app that will be configurable by the end-user to access SharePoint lists, on various different SharePoint sites, that are entered by the user.
All of the examples for reading SharePoint lists I've come across online are of the form:
Open or create a Visual Studio
project.
In Solution Explorer,
right-click the References node, and
then click Add Service Reference.
In the Address box, type the URL to
the target site and append
/_vti_bin/ListData.svc. For example,
the address for the site
intranet.wingtip.com would be
http://intranet.wingtip.com/_vti_bin/ListData.svc.
Change the default name in the
Namespace box from ServiceReference1
to something more appropriate, such
as WingtipSite.
etc, etc, etc
This method creates proxy classes within your project based on the specified server reference. However, in my case, the server/site is not known at design time, only runtime by reading the sites/lists specified by the user. How would one go about doing that (reading the list via http://intranet.wingtip.com/_vti_bin/ListData.svc, but at runtime only)?
Note: I am making this call from a different machine than the one running Sharepoint.
There are a couple answers.
If the lists schemas will be consistent across all the sites you are querying, you can still use the generated proxy. When you create the DataContext, you just need to pass in the URI to the ListData.svc for the site chosen by the user.
If not, then you can use an ASP.NET WebRequest with an appropriately formatted URI and parse out the ATOM or JSON response that comes back.
For more information on using the REST APIs, check out this talk from the 2009 SharePoint Conference
http://msdn.microsoft.com/en-us/sharepoint/ff462048
You can set the URL in your proxy class at runtime with the Url property.
SharePoint does not provide a proxy class for their web services. Therefore it's not possible to set the url at runtime. WHat I have had to do is add 2 service references and then paramaterize which one I will access. I use a config setting to determine which one to access. If the site name changes or list changes, then I need to remove the references, re-add them, recompile and redeploy. There is no way to change the SharePoint site/list at runtime. Have been searching for 3 days for an answer. Microsoft does not know how to accomplish this.

How to add bunch of aspx files to a site definition sp2010 vs2010 project

I need to be able to deploy bunch of aspx files when a site (sub-site aka web) is provisioned. I added a feature but it seems whole feature thing has changed with vs 2010 or sp2010. I am totally lost. All I want to do is to deploy these pages when a web is provisioned. Is it possible?
You can't drop aspx pages into SharePoint per say. If you want to add functionality, some of the options are:
1) Using Web Parts - probably the most popular method
2) User Controls
At the end of the day, you will create it as a Feature using VSeWSS 3.0 in VS and packaging/deploying it as a solution. Steer clear of trying to hack this up in SharePoint Designer - for one, you won't have source control like you have with a Feature.
http://www.andrewconnell.com/blog/articles/UsingCodeBehindFilesInSharePointSites.aspx
http://www.codersbarn.com/?tag=/webpart

SharePoint 2010: Point a PortalSiteMapProvider to a specific site collection

Is it possible to get an OOTB PortalSiteMapProvider to provide a site heirarchy from a specified site collection or URL (i.e. not the current site collection) in SharePoint 2010? In MOSS this was only possible by creating a custom SiteMapProvider, traversing the site collections and manually building the navigation tree.
NB: I am not prepared to write a
custom SiteMapProvider that reads from
a static XML (.sitemap) file as the regular site contributors may not have access to files on the file system.
A little bit of background... I have a single web application with 2x site collections:
1 for my intranet portal at http://intranet/ (publishing enabled)
1 for the My Sites at http://intranet/my (publishing not enabled)
We have no plans to facilitate multiple portals, therefore, I would like a consistant global navigation bar across both site collections. Ideally, I'd like the My Sites to show the site heirarchy from the main portal site. So is it possible to set the PortalSiteMapProvider.CurrentSite property to "http://intranet/" instead of "http://intranet/my"?
To achieve this behaviour I wrote my own web service which goes off and traverses another site collection's hierarchy (using it's own PortalSiteMapProvider), and returns that structure as an XML document. I obviously then bound my global navigation navigation menu to that.
I got the concept from here: PortalSiteMapProvider
There is a similar approach describes here which uses HttpHandlers instead: http://blog.symprogress.com/2011/03/sharepoint2010-custom-navigation-provider-cross-sitecollection/

SharePoint Web Part to View List from Different SharePoint Site

I am working on SharePoint 2010 instance. I want to be able to view list content in the SharePoint site that this list doesn't belong to. My site does not even share the same site collection as the one containing the list. Is this possible without the custom SharePoint solution coding? Thanks.
Here is a workaround:
http://sp2010.pathtosharepoint.com/SharePoint-User-Toolkit/Pages/Cross-Site-List-Snapshot.aspx
This will work across site collections, as long as the source and target pages are in the same domain. It'll work fine if your only purpose is to display the content, not use the context menus.
Other solutions like Data View Web Part or Content Query Web Part won't work across site collections.