How to create a custom enterprise wiki
1: Create a web template that extends the enterprise wiki template:
<?xml version="1.0" encoding="utf-8"?> <Templates xmlns:ows="Microsoft SharePoint"> <Template Name="YourWiki" ID="0"> <Configuration ID="0" Title="Your Enterprise Wiki" Hidden="FALSE" ImageUrl="/_layouts/images/stts.png" Description="..." DisplayCategory="Custom" ProvisionClass="<Namespace>.YourProvider" ProvisionAssembly="<namespace>, Version=1.0.0.0, Culture=neutral, PublicKeyToken=xxx" RootWebOnly="False"> </Configuration> </Template> </Templates>
2: Deploy the custom template to the folder: {SharePointRoot}\Template\1033\XML
3: Create the Custom Provider class:
class YourProvider : SPWebProvisioningProvider
{
public override void Provision(SPWebProvisioningProperties props)
{
props.Web.ApplyWebTemplate("ENTERWIKI#0")
var code = new SPSecurity.CodeToRunElevated(CreateSite);
SPSecurity.RunWithElevatedPrivileges(code); //Excecute elevated
}
private void CreateSite()
{
using (SPSite site = new SPSite(Properties.Web.Site.ID))
{
using (SPWeb web = site.OpenWeb(Properties.Web.ID))
{
// your custom code
}
}
}
}
That's it :)
No comments:
Post a Comment