sharepoint Feature Stapling, after page is created? - sharepoint

I have been adding lists and sites to sites when they have been created with feature stapling. Now I want to add a web part when a site is created but it seems like it is to early to do that in FeatureActivated() when I am using feature stapling.
It is working when I activate a feature for an already created site but when I try to do it with feature stapling a get an exception that the object is not created.
Do you know any why to accomplish this when the site is created?

Make sure you use the SPLimitedWebPartManager to perform this work, or you will have trouble.

I've been looking at Microsoft's own early example of how to build solutions - the GroupBoard Workspace solution (http://technet.microsoft.com/en-us/windowsserver/sharepoint/bb848080.aspx)
In this case they actually have two solutions - one which creates the site and another which "updates" the site afterwards. The webparts are added by the second one.

Related

Deploying site pages in SharePoint

I have around 9 web parts and 3 pages to be deployed. Each page will be having 3 webparts.
From a deploymnet perspective, i think i have the following two options:
Deploy the pages using a feature. The pages will have webparts present.
Create a custom site definition with a document library and have the three pages as part of the document library.
Can you please let me know which one of the options is better or is there any better solution?.
Please note that the solution needs to work on WSS 3.0 as well.
I would code the whole thing as a feature. You can staple it to the site definition for the site type you want it activated on.
If ever you need to migrate to the next version of SharePoint or another server it is easier to not have any custom site definitions. Also, the features leaves the site in a normal out-of-the box state; if you ever remove the feature nothing breaks.
Also, unlike the site definition it will also allow you to run it on sites that where created in the past.
First you need to deploy the webparts using WSP. Once it populated in webpart gallery you can copy the pages from page library and can paste in production.

Update base template and apply to all sites who reference it - MOSS 2007

More SharePoint questions from me again today! I thank everyone that has helped thus far!
Here is my situation:
I have to create a custom application inside of sharepoint. I am using a document library which hosts web part pages and i am using Web User Controls to do all the manipluating and displaying of data. Once I build the app the way i want, I am going to turn the doc lib into a template that way i can create the same thing on multiple sites (many customers using this app).
The issue that I am running into is that I need to know what happens/how do I update it so that my changes will apply itself to all sites that are referencing the template.
HELP! anyone who knows how to do this OR has a better idea for creating custom apps that multiple sites will be able to take advantage of would be SO helpful!
Thanks
Short answer is that you cannot accomplish this, even with a custom site/list definition.
Once a site or list is created from a site or list definition, it is basically on its own (layouts and master pages modifications, however, do get applied to all sites referencing them).
Once workaround would be to create a site feature that iterates through sites and performs whatever custom action you wish to do.
For requirement like this, you really should create custom list/site definition. NOT just save customized list into template.
Anything you have updated in list/site definition will be reflect to the sites that are referencing the definitions. Unfortunately this is not the case for Template. You will have to delete the old list you have on other sites, then re-create them again with new template.
how to create list definition - http://msdn.microsoft.com/en-us/library/ms466023.aspx
for site definition please go - http://technet.microsoft.com/en-us/library/cc287930.aspx
James

SharePoint 2007 Site Template Content Types

I am new to SharePoint development. We have created a base site template and have used that template to start new sites in other locations on the same server. This works fine but the newly created site seems to "flatten" the custom content types created in the original site. I would think there would be a way to keep the original content type inheritance intact to help support any necessary modifications on the new site. They can still make the modifications but they take longer because you have to visit each list individually. Does anyone know how to fix this or know a better way to approach this?
The problem you are having is the move from your original site collection to another. The site template does not store the complete definition of a site - only the differences from the underlying site definition. Move from one site collection to another and you lose the underlying site definition and run into problems such as the loss of your content types.
Site templates and site definitions are two separate customizations you can undertake. You need to make a decision based on your requirements as to which is best.
Site templates
Pro's:
Easy to create and reuse through the SharePoint interface
Ideal for end users
A site template is a customization of the underlying default site definition
Con's:
Dependency on underlying site definition means SharePoint updates could break your site templates
Poor performance since the modifications are held in the database and are read from the DB and compiled on each request
Limited customization options
Site definitions
Pro's:
Harder to create: involves coding XML
Made by developers and site administrators
Independent of SharePoint default site definitions so not affected by SharePoint updates
Limitless customization options
Con's:
Difficult to modify when deployed
Can be cached on the file system so is fast to load
Check out Google for info on creating custom site definitions.
Hope this helps!
Jonny
The best way to do this is to create a site definition where the content types are within features whose scope is to the farm.
Tim

Creating a Sharepoint solution from a site (including workflows and custom webparts)

Here's the scenario
I created a Site which in I used custom lists, webparts, custom developed webparts, workflows et cetera. You can see the site as an application.
What I am trying to do is to create a solution package which holds everything I build in that site so that I can give the solution file to an sharepoint administrator who can install the solution to his sharepoint environment.
For example look at the free application templates you can download from MSDN, I am trying to achieve the same as they did. One solution file to hold them all!
Any idea's?
Cheers!
Get STSDev and SharePoint Manager. STSDev is goog for creating the solution you want and SharePoint Manager can be used to get the SchemaXML from the customisations you have already created.
You will need to package up the webparts and everything. Unfortunately, this is a pretty hefty learning curve, so expect to do a lot of reading on this subject and some experimentation. However, this is time well spent as a solution is the "only" way to release a custom site definition.
Workflows created using SPD are not portable across sites - they will have to be recreated. As a result, Nathan's solution is probably going to be the only way to go.
Export the site as a template and include all the content. The workflows will point at the old site and will need to be updated manually, I believe. Everything else should work.

Sharepoint: Deploy Custom Lists and New Columns in lists

I've created a custom list & also added a column in the Announcement List. Question is, how can I include those newly created items when I create a fresh Web Application (like a script, feature or something)?
Additional Info: It's like when you're to deploy from your development machine to a staging or production server. I'd like to have a script or something to update my production server to have the new column i've added to the Announcement List. Just like SQL Server's ALTER TABLE command to update a SQL Server Table.
Is there an equivalent in Sharepoint Lists?
TIA!
Regarding the new custom list, this can be done using features. See How to: Create a Custom List Definition for more information. The Visual Studio Extensions for SharePoint (VS2005 / VS2008) will help you to extract the list definition if you've created it through the SharePoint UI. If you are fortunate enough to be using a custom site definition and don't have any webs created yet, you can set your site definition to create the custom list using feature stapling.
If you are attempting to apply these changes to webs that already exist, you can still use a feature to define your custom list. It will just appear as a type of list that can be created. Then to have the custom list automatically created for existing webs or to modify existing lists such as the Announcements list, you can use a feature receiver. This allows you to run any custom code when the feature is activated. See the MSDN article Feature Events for more information.
Alternatively, you could not use features at all as they can be difficult, time consuming and painful. In fact, this blog post has a good argument against the idea. You could try the tool mentioned on that page or other applications such as DocAve Content Manager and SharePoint Site Migration Manager.
Your question is not very clear but I think you may want to look at Application Templates.
Microsoft provide 40 pre-built templates in the link below and the same technology is available to you. Links from this page should lead you to information showing you how you can crate your own.
Application Templates for Windows SharePoint Services 3.0
http://technet.microsoft.com/en-us/windowsserver/sharepoint/bb407286.aspx

Resources