Customization of site definitions holds the following advantages over custom templates:
Data is stored directly on the Web servers, so performance is typically better.
A higher level of list customization is possible through direct editing of a SCHEMA.XML file.
Certain kinds of customization to sites or lists require use of site definitions, such as introducing new file types, defining view styles, or modifying the drop-down Edit menu.
Site definition disadvantages include the following:
Customization of site definition requires more effort than creating custom templates.
It is difficult to edit a site definition after it has been deployed.
Doing anything other than adding code can break existing sites.
Users cannot apply a SharePoint theme through a site definition.
Users cannot create two lists of the same type with different default content.
Customizing site definitions requires access to the file system of the front-end Web server.
Custom templates hold the following advantages over customization of site definitions:
Custom templates are easy to create.
Almost anything that can be done in the user interface can be preserved in the template.
Custom templates can be modified without affecting existing sites that have been created from the templates.
Custom templates are easy to deploy.
Custom template disadvantages include the following:
Custom templates are not created in a development environment.
They are less efficient in large-scale environments.
If the site definition on which the custom template is based does not exist on the front-end server or servers, the custom template will not work.
Wednesday, April 20, 2011
Schema Files in Sharepoint
Core Schema Files
The following table describes prominent XML files that can be modified for a site definition and shows their locations in the file system.
DOCICON.XML
Maps file ProgIDs and file extensions of document types to specific icons and to controls for opening each type.
\TEMPLATE\XML
WEBTEMP.XML
Specifies configurations for site definitions
\TEMPLATE\1033\XML
ONET.XML
Defines the navigation areas, specifies the list definitions available on the Create Page, specifies document templates and their files, defines the base types for lists, and defines configurations and modules for site definitions.
\TEMPLATE\1033\STS\XML
SCHEMA.XML
Defines the views, forms, toolbar, and special fields in a list definition. Each definition has its own SCHEMA.XML file.
\TEMPLATE\1033\STS\LISTS\List_Definition_Name
The following table describes prominent XML files that can be modified for a site definition and shows their locations in the file system.
DOCICON.XML
Maps file ProgIDs and file extensions of document types to specific icons and to controls for opening each type.
\TEMPLATE\XML
WEBTEMP.XML
Specifies configurations for site definitions
\TEMPLATE\1033\XML
ONET.XML
Defines the navigation areas, specifies the list definitions available on the Create Page, specifies document templates and their files, defines the base types for lists, and defines configurations and modules for site definitions.
\TEMPLATE\1033\STS\XML
SCHEMA.XML
Defines the views, forms, toolbar, and special fields in a list definition. Each definition has its own SCHEMA.XML file.
\TEMPLATE\1033\STS\LISTS\List_Definition_Name
Tuesday, April 19, 2011
SPSite site = new SPSite("sitename");
SPWeb Web = site.OpenWeb();
SPNavigationNodeCollection nodes = Web.Navigation.QuickLaunch;
SPNavigationNode NavNodeWorkingDoc = null;
SPNavigationNode NavNodePicLib = null;
SPNavigationNode NavNodeRefLib = null;
SPNavigationNode navNodeFinalDoc = null;
SPNavigationNode navNodePublished = null;
SPNavigationNode navNodeDisclosed = null;
foreach (SPNavigationNode node in nodes)
{
if (node.Title.Equals("Documents")) //Documents
{
foreach (SPNavigationNode childnode in node.Children)
{
if (childnode.Title.Equals("Documents"))
{
childnode.Delete();
//childnode.Url = "url name"
}
else if (childnode.Title.Equals("Project Documents"))
{
NavNodeWorkingDoc = childnode;
NavNodeWorkingDoc.Title = "Working Documents";
NavNodeWorkingDoc.Update();
}
else if (childnode.Title.Equals("Picture Library"))
{
NavNodePicLib = childnode;
NavNodePicLib.Title = "Picture Gallery";
NavNodePicLib.Update();
}
else if (childnode.Title.Equals("Reference Library"))
{
NavNodeRefLib = childnode;
}
}
node.Children.Add(navNodeFinalDoc, NavNodeRefLib);
node.Children.Add(navNodePublished, navNodeFinalDoc);
node.Children.Add(navNodeDisclosed, navNodePublished);
}
}
SPWeb Web = site.OpenWeb();
SPNavigationNodeCollection nodes = Web.Navigation.QuickLaunch;
SPNavigationNode NavNodeWorkingDoc = null;
SPNavigationNode NavNodePicLib = null;
SPNavigationNode NavNodeRefLib = null;
SPNavigationNode navNodeFinalDoc = null;
SPNavigationNode navNodePublished = null;
SPNavigationNode navNodeDisclosed = null;
foreach (SPNavigationNode node in nodes)
{
if (node.Title.Equals("Documents")) //Documents
{
foreach (SPNavigationNode childnode in node.Children)
{
if (childnode.Title.Equals("Documents"))
{
childnode.Delete();
//childnode.Url = "url name"
}
else if (childnode.Title.Equals("Project Documents"))
{
NavNodeWorkingDoc = childnode;
NavNodeWorkingDoc.Title = "Working Documents";
NavNodeWorkingDoc.Update();
}
else if (childnode.Title.Equals("Picture Library"))
{
NavNodePicLib = childnode;
NavNodePicLib.Title = "Picture Gallery";
NavNodePicLib.Update();
}
else if (childnode.Title.Equals("Reference Library"))
{
NavNodeRefLib = childnode;
}
}
node.Children.Add(navNodeFinalDoc, NavNodeRefLib);
node.Children.Add(navNodePublished, navNodeFinalDoc);
node.Children.Add(navNodeDisclosed, navNodePublished);
}
}
attach Event Receivers to content types in sharepoint
using System;
using System.Collections;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Security;
using Microsoft.SharePoint.Administration;
namespace SuryaFeature
{
///
/// This class handles events raised during feature activation, deactivation, installation, uninstallation, and upgrade.
///
///
/// The GUID attached to this class may be used during packaging and should not be modified.
///
[Guid("65b846e7-1d25-4396-bdab-36db28bb9a3e")]
public class FeatureEventReceiver : SPFeatureReceiver
{
private string sAssemblyFullName = string.Empty;
private string sClassName = string.Empty;
private string sOperationMode = string.Empty;
private SPEventReceiverDefinitionCollection oEventRecvDefColl = null;
private string[] sArrContentTypeNames = { "Leave Calendar", "Event Calendar", "Editorial Calendar" };
// Uncomment the method below to handle the event raised after a feature has been activated.
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
sOperationMode = "Activate";
PerformOperation(properties);
}
// Uncomment the method below to handle the event raised before a feature is deactivated.
public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
{
sOperationMode = "Deactivate";
PerformOperation(properties);
}
private void GetAssemblyParameters(SPFeaturePropertyCollection properties)
{
sClassName = properties["AssemblyQualifiedName"].Value;
sAssemblyFullName = properties["AssemblyFullName"].Value;
}
private void PerformOperation(SPFeatureReceiverProperties _oProperties)
{
try
{
using (SPWeb oWeb = _oProperties.Feature.Parent as SPWeb)
{
GetAssemblyParameters(_oProperties.Feature.Properties);
SPListCollection oIntranetListColl = oWeb.Lists;
for (int iCount = 0; iCount < oIntranetListColl.Count; iCount++) { if (CheckForContentType(oIntranetListColl[iCount])) { // call this procedure to delete any existing event handlers DeleteEventHandlerToContentType(oIntranetListColl[iCount]); if (sOperationMode == "Activate") { SPEventReceiverDefinition oEventRecvDef = null; foreach (string _sArrItem in sArrContentTypeNames) { AddEventHandlerToContentType(oIntranetListColl[iCount], oEventRecvDef, "ItemAdding" + _sArrItem.Replace(" ", ""), SPEventReceiverType.ItemAdding, 1000, SPEventReceiverSynchronization.Synchronous); AddEventHandlerToContentType(oIntranetListColl[iCount], oEventRecvDef, "ItemUpdating" + _sArrItem.Replace(" ", ""), SPEventReceiverType.ItemUpdating, 1001, SPEventReceiverSynchronization.Synchronous); AddEventHandlerToContentType(oIntranetListColl[iCount], oEventRecvDef, "ItemDeleting" + _sArrItem.Replace(" ", ""), SPEventReceiverType.ItemDeleting, 1002, SPEventReceiverSynchronization.Synchronous); } } } } } } catch (Exception eEX) { SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory("TravelCalendarFeatureReceiver", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, eEX.Message, eEX.StackTrace); } } private bool CheckForContentType(SPList _oListToUpdate) { if (_oListToUpdate.ContentTypes.Count > 0)
{
foreach (SPContentType _oContentType in _oListToUpdate.ContentTypes)
{
if (sArrContentTypeNames.Contains(_oContentType.Name)) { return true; }
}
}
return false;
}
private void DeleteEventHandlerToContentType(SPList _oListToUpdate)
{
// get all event receviers as definition collection
oEventRecvDefColl = _oListToUpdate.EventReceivers;
SPEventReceiverDefinition oEventRecvToDelete;
// create an array to store event receivers chosen for deletion
ArrayList oArrEventRecvToDelete = new ArrayList();
for (int i = 0; i < oEventRecvDefColl.Count; i++) { oEventRecvToDelete = oEventRecvDefColl[i]; if (oEventRecvToDelete.Type == SPEventReceiverType.ItemAdding) { oEventRecvToDelete.Delete(); } if (oEventRecvToDelete.Type == SPEventReceiverType.ItemUpdating) { oEventRecvToDelete.Delete(); } if (oEventRecvToDelete.Type == SPEventReceiverType.ItemDeleting) { oEventRecvToDelete.Delete(); } } } private void AddEventHandlerToContentType(SPList _oListToUpdate, SPEventReceiverDefinition _oEventRecvDef, string _sEventRecvDefName, SPEventReceiverType _oEventRecvType, int _iEventRecvSeq, SPEventReceiverSynchronization _oEventRecvSyn) { _oEventRecvDef = _oListToUpdate.EventReceivers.Add(); _oEventRecvDef.Assembly = sAssemblyFullName; _oEventRecvDef.Class = sClassName.Substring(0, sClassName.IndexOf(',')); _oEventRecvDef.Name = _sEventRecvDefName; _oEventRecvDef.Type = _oEventRecvType; _oEventRecvDef.SequenceNumber = _iEventRecvSeq; _oEventRecvDef.Synchronization = _oEventRecvSyn; _oEventRecvDef.Update(); } // Uncomment the method below to handle the event raised after a feature has been installed. //public override void FeatureInstalled(SPFeatureReceiverProperties properties) //{ //} // Uncomment the method below to handle the event raised before a feature is uninstalled. //public override void FeatureUninstalling(SPFeatureReceiverProperties properties) //{ //} // Uncomment the method below to handle the event raised when a feature is upgrading. //public override void FeatureUpgrading(SPFeatureReceiverProperties properties, string upgradeActionName, System.Collections.Generic.IDictionary parameters)
//{
//}
}
}
using System.Collections;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Security;
using Microsoft.SharePoint.Administration;
namespace SuryaFeature
{
///
/// This class handles events raised during feature activation, deactivation, installation, uninstallation, and upgrade.
///
///
/// The GUID attached to this class may be used during packaging and should not be modified.
///
[Guid("65b846e7-1d25-4396-bdab-36db28bb9a3e")]
public class FeatureEventReceiver : SPFeatureReceiver
{
private string sAssemblyFullName = string.Empty;
private string sClassName = string.Empty;
private string sOperationMode = string.Empty;
private SPEventReceiverDefinitionCollection oEventRecvDefColl = null;
private string[] sArrContentTypeNames = { "Leave Calendar", "Event Calendar", "Editorial Calendar" };
// Uncomment the method below to handle the event raised after a feature has been activated.
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
sOperationMode = "Activate";
PerformOperation(properties);
}
// Uncomment the method below to handle the event raised before a feature is deactivated.
public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
{
sOperationMode = "Deactivate";
PerformOperation(properties);
}
private void GetAssemblyParameters(SPFeaturePropertyCollection properties)
{
sClassName = properties["AssemblyQualifiedName"].Value;
sAssemblyFullName = properties["AssemblyFullName"].Value;
}
private void PerformOperation(SPFeatureReceiverProperties _oProperties)
{
try
{
using (SPWeb oWeb = _oProperties.Feature.Parent as SPWeb)
{
GetAssemblyParameters(_oProperties.Feature.Properties);
SPListCollection oIntranetListColl = oWeb.Lists;
for (int iCount = 0; iCount < oIntranetListColl.Count; iCount++) { if (CheckForContentType(oIntranetListColl[iCount])) { // call this procedure to delete any existing event handlers DeleteEventHandlerToContentType(oIntranetListColl[iCount]); if (sOperationMode == "Activate") { SPEventReceiverDefinition oEventRecvDef = null; foreach (string _sArrItem in sArrContentTypeNames) { AddEventHandlerToContentType(oIntranetListColl[iCount], oEventRecvDef, "ItemAdding" + _sArrItem.Replace(" ", ""), SPEventReceiverType.ItemAdding, 1000, SPEventReceiverSynchronization.Synchronous); AddEventHandlerToContentType(oIntranetListColl[iCount], oEventRecvDef, "ItemUpdating" + _sArrItem.Replace(" ", ""), SPEventReceiverType.ItemUpdating, 1001, SPEventReceiverSynchronization.Synchronous); AddEventHandlerToContentType(oIntranetListColl[iCount], oEventRecvDef, "ItemDeleting" + _sArrItem.Replace(" ", ""), SPEventReceiverType.ItemDeleting, 1002, SPEventReceiverSynchronization.Synchronous); } } } } } } catch (Exception eEX) { SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory("TravelCalendarFeatureReceiver", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, eEX.Message, eEX.StackTrace); } } private bool CheckForContentType(SPList _oListToUpdate) { if (_oListToUpdate.ContentTypes.Count > 0)
{
foreach (SPContentType _oContentType in _oListToUpdate.ContentTypes)
{
if (sArrContentTypeNames.Contains(_oContentType.Name)) { return true; }
}
}
return false;
}
private void DeleteEventHandlerToContentType(SPList _oListToUpdate)
{
// get all event receviers as definition collection
oEventRecvDefColl = _oListToUpdate.EventReceivers;
SPEventReceiverDefinition oEventRecvToDelete;
// create an array to store event receivers chosen for deletion
ArrayList oArrEventRecvToDelete = new ArrayList();
for (int i = 0; i < oEventRecvDefColl.Count; i++) { oEventRecvToDelete = oEventRecvDefColl[i]; if (oEventRecvToDelete.Type == SPEventReceiverType.ItemAdding) { oEventRecvToDelete.Delete(); } if (oEventRecvToDelete.Type == SPEventReceiverType.ItemUpdating) { oEventRecvToDelete.Delete(); } if (oEventRecvToDelete.Type == SPEventReceiverType.ItemDeleting) { oEventRecvToDelete.Delete(); } } } private void AddEventHandlerToContentType(SPList _oListToUpdate, SPEventReceiverDefinition _oEventRecvDef, string _sEventRecvDefName, SPEventReceiverType _oEventRecvType, int _iEventRecvSeq, SPEventReceiverSynchronization _oEventRecvSyn) { _oEventRecvDef = _oListToUpdate.EventReceivers.Add(); _oEventRecvDef.Assembly = sAssemblyFullName; _oEventRecvDef.Class = sClassName.Substring(0, sClassName.IndexOf(',')); _oEventRecvDef.Name = _sEventRecvDefName; _oEventRecvDef.Type = _oEventRecvType; _oEventRecvDef.SequenceNumber = _iEventRecvSeq; _oEventRecvDef.Synchronization = _oEventRecvSyn; _oEventRecvDef.Update(); } // Uncomment the method below to handle the event raised after a feature has been installed. //public override void FeatureInstalled(SPFeatureReceiverProperties properties) //{ //} // Uncomment the method below to handle the event raised before a feature is uninstalled. //public override void FeatureUninstalling(SPFeatureReceiverProperties properties) //{ //} // Uncomment the method below to handle the event raised when a feature is upgrading. //public override void FeatureUpgrading(SPFeatureReceiverProperties properties, string upgradeActionName, System.Collections.Generic.IDictionary
//{
//}
}
}
attach w3wp.exe in sharepoint
if you dont know your w3wp.exe id to attach to debugger , use below command.
open command prompt
c:\windows32\system32\inetsrv> appcmd list wp
open command prompt
c:\windows32\system32\inetsrv> appcmd list wp
your client does not support opening this list with windows explorer
try this :
http://www.microsoft.com/downloads/en/details.aspx?familyid=7554F536-8C28-4598-9B72-EF94E038C891&displaylang=en",,-1,0,,,,
http://www.microsoft.com/downloads/en/details.aspx?familyid=7554F536-8C28-4598-9B72-EF94E038C891&displaylang=en",,-1,0,,,,
Subscribe to:
Posts (Atom)