I am developing a sharepoint feature which takes a backup of the site at sitecollection level and at site level whenever a user tries to delete the site. The feature is working fine without issues for the existing sitecollection and sites when the feature is activated. To give more picture, i am taking backup through code in events SiteDeleting and WebDeleting events. This events are hooked up using FeatureActivated event. I understand this ensures the event are hooked only up for the existing sites because of my code(i am hooking SiteDeleting and WebDeleting events in FeatureActivated event). After the feature activated, if i create a new site collection/sites the feature is not working(i.e backup is not taken when deleting the site).
I was trying to activate the event for new sites and hence i looked if there will be similar events like sitecreating where i can again hook up the SiteDeleting and WebDeleting events for new sites. But i came to know after some reasearch that there is no sitecreating event which can be used. After bit of googling i found that it can be done through a feature called stapling where we need to create another feature that attaches this feature to the new sites through template name. I have tried installing both the feature(my original and stapling feature) but it never seems to be working...
I am very new to SharePoint development and its taking time for fixing it. It will great if someone can help me to make the feature to work for the new sites as well.. I believe i am doing something wrong in scope parameter of feature.xml..listed below the feature.xml contents.
SiteDeletFeature (My original Feature) *Feature.xml* <
?xml version="1.0" encoding="utf-8" ?> <Feature Title="My SharePoint Delete Feature" Scope ="WebApplication" ActivateOnDefault="True" Hidden="false" Id="DA910034-F270-4932-90D0-05AE2EE13192" xmlns="http://schemas.microsoft.com/sharepoint/" ReceiverAssembly="My.Sharepoint.SiteDeleteFeature, Version=22.214.171.124, Culture=neutral, PublicKeyToken=762e98b8afce5f9b" ReceiverClass="My.Sharepoint.SiteDeleteFeature.DeleteFeatureCallOut"> <ElementManifests> <ElementManifest Location="Elements.xml"/> </ElementManifests> </Feature>
<?xml version="1.0" encoding="utf-8" ?> <!-- Copyright (c) Microsoft Corporation. All rights reserved. --> <Feature xmlns="http://schemas.microsoft.com/sharepoint/" Id="D0495B32-9F78-4142-A456-48B3ECBFFD6C" ActivateOnDefault="True" Title="My SharePoint Delete Feature" Description="My SharePoint Delete Feature" Version="0.0.0.0" Scope="Farm"> <ElementManifests> <ElementManifest Location="FeatureStapling\FeatureStapling.xml" /> </ElementManifests> </Feature>
<?xml version="1.0" encoding="utf-8" ?> <!-- Copyright (c) Microsoft Corporation. All rights reserved. --> <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <FeatureSiteTemplateAssociation Id="DA910034-F270-4932-90D0-05AE2EE13192" TemplateName="STS#0" /> . . .//goes on, i have included all template names <FeatureSiteTemplateAssociation Id="DA910034-F270-4932-90D0-05AE2EE13192" TemplateName="MyCOMMUNITY" /> </Elements>
I have tried various option in Scope parameter for SiteDeleteFeatureStapling like Web,Site but nothing worked out...
Could someone help me to fix this issue?