Change the default page when site is created
When you create a new publishing site in MOSS it automatically gets a default page created using the WelcomeLinks.aspx page layout. How can you change this behavior and have it automatically create a page based on a content type and page layout of your choice? Read on to find out how.
The Publishing template (as do all templates) have an ONET.XML file. In this file there is a modules section (as below), this defines the PublishingPageLayout and ContentType to be used when a site is created.
<Modules> <Module Name="Home" Url="$Resources:cmscore,List_Pages_UrlName;" Path=""> <File Url="default.aspx" Type="GhostableInLibrary" Level="Draft" > <Property Name="Title" Value="$Resources:cmscore,IPPT_HomeWelcomePage_Title;" /> <Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/WelcomeLinks.aspx, ~SiteCollection/_catalogs/masterpage/WelcomeLinks.aspx" /> <Property Name="ContentType" Value="$Resources:cmscore,contenttype_welcomepage_name;" /> </File> </Module> </Modules>
This could be changed to specify any default content type and page layout. The following shows how you might change it to a content type called MyContentType and a default page layout called MyPageLayout.aspx;
<Modules> <Module Name="Home" Url="$Resources:cmscore,List_Pages_UrlName;" Path=""> <File Url="default.aspx" Type="GhostableInLibrary" Level="Draft" > <Property Name="Title" Value="$Resources:cmscore,IPPT_HomeWelcomePage_Title;" /> <Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/MyPageLayout.aspx, ~SiteCollection/_catalogs/masterpage/MyPageLayout.aspx" /> <Property Name="ContentType" Value="MyContentType" /> <Property Name="PublishingAssociatedContentType" Value=";#MyContentType;#0x010100C568…3A09F31E1FBA;#" /> </File> </Module> </Modules>
Note: The big number 0x010100C568…3A09F31E1FBA is obtained from the Url of the Content Type.
Comments
Anonymous
January 31, 2008
CaitPSU Says: April 10, 2007 at 8:04 am How can you access the ONET.xml file? Can it be done through Sharepoint Designer? I’d rather not go into the file system - is there a way? ThanksAnonymous
January 31, 2008
Code Jedi Says: April 12, 2007 at 7:58 pm I personnally am not concerned with accessing files in the file system and use Visual Studio to do such, although file explorer and notepad would suffice.Anonymous
January 31, 2008
anabhra Says: April 15, 2007 at 9:11 am I tried this without much luck. The ONET.XMl file that I modified was in this path C:Program FilesCommon FilesMicrosoft Sharedweb server extensions12TEMPLATESiteTemplatesPUBLISHINGXML. and this how I changed it (after creating a content type and page layout, both called CMSDefault) - Does this seem right? thanks, anabhraAnonymous
January 31, 2008
Code Jedi Says: April 15, 2007 at 9:15 am Did you perform an IISReset for the changes in the ONET.XML to be picked up. Also note the ONET.XML file is only used for the initial site creation and any changes made do not affect any existing sites already created from it.Anonymous
January 31, 2008
anabhra Says: April 15, 2007 at 12:32 pm Thanks William. I did perform the IISReset. What I am trying to do is configure the default page for a group of child sites (publishing sites) under the parent publishing site that is the root application. So say http://severname:9001 is the application that I create as a publishing site. What I want is a default page for all 1st level children sites (http://server:9001/Media/) and another default page for 2nd level children sites (http://server:9001/Media/WorldNews/). Can this be done? Thanks, anabhraAnonymous
January 31, 2008
The comment has been removedAnonymous
January 31, 2008
anabhra Says: April 16, 2007 at 12:51 am Yes, you are right. However, I have to create about eight 1st level sites and about 50 2nd level sites. A templated way to create them would come handy. Also, I have to replicate this effort accross 8 variation sites. Can’t I save my 1st level or 2nd levelsub site as a template and reuse? thanks, anabhraAnonymous
January 31, 2008
Sezai Says: October 2, 2007 at 6:58 pm I too have been having problems getting this working, i think I finally have it sussed. Check out this blog post : http://katriendg.com/aboutdotnet/2007-5-1-publishing-web-syntax-onet-xml.aspx It states you need to make use of a ‘ContentTypeBinding’ feature so on creation of a new sub-site your custom content type is added to the Pages document library, so that the welcome page IS created correctly with your custom content type. Otherwise the correct page layout is used, but if you switch to ‘Edit’ mode on the new welcome page any field controls bound to new custom fields won’t render because the actual content type used for the page is ‘Page’ and not your custom content type.