سؤال

I am building a MOSS2010 app. I want to make a custom site definition, which, in itself, will have sites (So it'll be like a site collection which I really want). I want to do this preferably via C# only.

What would be the best way? It seems like site definitions are not up for this.

Thanks

هل كانت مفيدة؟

المحلول

If your site hierarchy is already known at design time, you could implement in the web UI, then save it as a Site Template.

نصائح أخرى

An easy way to do this is to use the OOB site provisioning provider that BLANKINTERNET uses (see example of this in stswebtemp.xml and accompaning site hierarchy manifest file).

An alternative is to use a custom provisioning provider in which you programmatically create sub sites (preferably in an XML file). Reuse the provisioning provider in the web template for the sub sites for creating hierarchies.

sharepoint provisioning provider

Another option is to use PowerShell. Define an XML structure that defines webs/subwebs (reuse the structure of the OOB provisioning provider if u like) and iterate it while creating New-SPWeb

  • You can scope your site definition to only create site at Root of site collection (via webtemp.xnl file).

  • You can create a stapler feature that associates your site definition with another feature say X. Further you can write a feature receiver class for feature X where in using the Feature Activated event you can use the SharePoint object model and create the required sub sites in your site collection.

Although I haven't tried it myself, I believe it's possible to leverage the "PortalProvisioningProvider" class which is used by some of SharePoint's default site definitions. This class reads a separate XML file describing the subsite hierarchy. See here for details.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى sharepoint.stackexchange
scroll top