So, a good start with a posting today about one of the chalanges we've been dealing with the last couple of weeks. For our customer we want to create a customized wiki definition, with some additional fields and layout. Normally you would think to copy the wiki site definition and change the onet.xml and the list dinition for the additional fields. So this is what we did, and it turns out to work ok. But changing the layout of the wiki page itself is something different...
If you dive into the Wiki content type (I used sharepoint inspector to easily see the properties), you will see that when you create a new page, the 'CreateWebPage.aspx' page is called on the layouts directory.
This page makes sure the wiki page is created and a template file is connected to it called 'wkpstd.aspx' in the DocumentTemplates directory (C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\DocumentTemplates). This page takes are of the layout of the wiki page.
So, changing this page will change the layouts of all wiki pages, which is not supported and probably not what you want to do. Therefore, you have to change the onet.xml of the wiki site difinition to mention that the template that will be used is another one. In out case a copy stored on the same directory (i.e. wkpstd_custom.aspx). In the onet.xml we've changed the wkpstd.aspx to our custom page.
<Module Name="DefaultWikiPages" List="1119" Url="$Resources:core,WikiWebLibPages_Folder;" Path="" SetupPath="DocumentTemplates">
<File Url="wkpstd_custom.aspx" Name="$Resources:core,nav_Home;.aspx" Type="GhostableInLibrary">
<Property Name="WikiField" Value="$Resources:core,WikiHomeContent;" />
<NavBarPage Name="$Resources:core,nav_Home;" ID="1002" Position="Start" />
<NavBarPage Name="$Resources:core,nav_Home;" ID="1010" Position="Start" />
</File>
<File Url="wkpstd_custom.aspx" Name="$Resources:core,nav_HowToUseThisWikiSite;.aspx" Type="GhostableInLibrary">
<Property Name="WikiField" Value="$Resources:core,WikiHowToUseContent_Part1;$Resources:core,WikiHowToUseContent_Part2;$Resources:core,
WikiHowToUseContent_Part3;$Resources:core,WikiHowToUseContent_Part4;$Resources:core,WikiHowToUseContent_Part5;$Resources:core,
WikiHowToUseContent_Part6;$Resources:core,WikiHowToUseContent_Part7;$Resources:core,WikiHowToUseContent_Part8;" />
<NavBarPage Name="$Resources:core,nav_HowToUseThisWikiSite;" ID="1010" />
</File>
</Module>
But now the pages that are created by this site definition will have the new layout, all new created wiki pages stange enough not... So what happens? Somehow, in the CreateWebPage.aspx file, the wkpstd.aspx is 'hardcoded' used and there are two options to avoid that:
- Create a new CreateWebPage.aspx file with your own custom code. This page will create new pages based on the new custom aspx file as a template
- Create an eventhandler that will activate with the site definition that programatically sets the template page for each new created wiki page.
Personally I would prefer the second option, but that's up to you. Anyway learning something new everyday! Also thanks to my colleague Wouter for also researching this. :)
Some more info on the net can be found here.