Changing the CreateSite page


After seeing the templateID detail (http://blogs.msdn.com/dwinter/archive/2006/07/07/659613.aspx) ChrisF wanted to know if there was an ID associated with the Custom Tab that shows up on the Create New Page.  He was trying to make that tab the default tab that shows up.  Here is my response:

If you look at …\12\TEMPLATE\ADMIN\createsite.aspx, you’ll see that dialog is simply represented by:
    <wssuc:TemplatePickerControl id=”InputFormTemplatePickerControl” runat=”server” ShowSubWebOnly=”false” ShowCustomTemplates=”false” />
Look at the definition of wssuc:TemplatePickerControl in the Register directives at the top of the page and you’ll find that it is comming from ~/_controltemplates/TemplatePickerControl.ascx.  Go open that (its in: …\12\TEMPLATE\CONTROLTEMPLATES) and you’ll see this:
    <input type=”hidden” ID=”HiddenSelectedCategory” value=”” runat=”server”/>
You might think that you could make this something like:
    <input type=”hidden” ID=”HiddenSelectedCategory” value=”Publishing” runat=”server”/>
however, the hidden tag is used only on postback–so it won’t help you on page load.

Your only real answer here is to use querystrings on the inbound URL.  If you browse to createsite.aspx with a DisplayCategory querystring, the control will filter.  For example:
    http://server:centraladmin/_admin/createsite.aspx?DisplayCategory=Publishing
Alternatively, if you browse to createsite.aspx with an ID querystring, the control will also filter.  For example:
    http://server:centraladmin/_admin/createsite.aspx?ID=2
will just show MPS configurations, and:
    http://server:centraladmin/_admin/createsite.aspx?ID=47
will show the Collaboration Portal as the only choice.

Now your next question (and what ChrisF was getting at) is–how do I make the UI do this?  The answer, edit the …\12\TEMPLATE\FEATURES\AdminLinks\Applications.xml
Look for CreateSite, you will see:
       <UrlAction
           Url=”/_admin/createsite.aspx” />
Make this (for example):
       <UrlAction
           Url=”/_admin/createsite.aspx?DisplayCategory=Publishing” />

Save it and refresh the page.  You’ll see the link is now updated.  
Now I have to throw out the disclaimer that this modification may need to be redone/removed with a servicepack, hotfix, or upgrade to o14 (make sure you let CSS know you made this change if you call with an issue with Central Admin).  However, if you decide to accept the risk associated with this kind of change, yes you can make it happen.

Comments (7)

  1. phammk@aol.com says:

    I’m trying to implement this code thru ASP.Net using a Web Service, and stuck with Credential problem. Whether i use, Impersonation, creatting new CredentialCache, or even running under special App Pool with Local Admin rights, i can not connect to the Sharepoint Site.

    The code works wonderful, IF i execute it inside Visual Studio 2005.

    I’ve searched the WEB without any luck. Could you assist in any way ?

    SPWeb mySite = SPControl.GetContextWeb(Context);

    SPWebCollection subSites = mySite.Webs;

    string currentTemplate = mySite.WebTemplate;

    subSites.Add(siteUrl, siteTitle, siteDescription, 1033, currentTemplate, true, false);

  2. phammk@aol.com says:

    Forgot to mention that this is for MOSS 2007

  3. Based on what you said, there’s a good chance that the user that is attempting to actually execute the SPWebCollection.Add is the user that is browsing.  You will more likely want to have the application pool do this for the user, so prior to that block of code, elevate your privledges with this:

      System.Security.Principal.WindowsImpersonationContext _windowsImpersonationContext = System.Security.Principal.WindowsIdentity.Impersonate(IntPtr.Zero);

    and after it, return control back to the user with this:

      _windowsImpersonationContext.Undo();

    If you do not call Undo after such an operation, you will continue to execute as the app pool account, and this could cause problems and/or unexpected behaviors.

  4. ChrisF says:

    Thanks for the help.  I should have said it in my post but the page that I was having the problem with was actually newsbweb.aspx with MOSS 2007.  I was able to apply what you said in the post to my page and it works like a champ.  I knew it had to be something easy that I was looking over.

    Might I ask you a follow up question.  With regards to the Custom Tab on newsbweb.aspx using MOSS 2007.  Is there a way to rename the Custom Tab and to have a different image show up when a custom template is choosen?  I know that is you go into the webtemp.xml file you are able to make changes to the pre-exisiting templates but I can find no reference to the Custom Template.  I’m thinking that it might be the the database some where but can’t find it as well.

    Thanks for all the help..

  5. DDJ says:

    This seems to work for newsbweb.aspx.  

    function setCustom()

    {

      GetWebTemplates(‘1033&Custom’, ‘context’);

    }

    setTimeout("setCustom();", 200);

  6. lolag says:

    Hello all,

    I need some help!!

    When working with calendars there is an option to create �Meeting Workspaces�. When you click on this you could select from a list of Meeting workspaces templates (these templates seem to have a different id than regular sites or document workspaces). I need to make a document workspace template available in the meeting template list, is that possible? Secondly, how can I do that?

    _layouts/templatepick.aspx?FieldSource=WorkspaceLink&CPLinkSource=Workspace&List=%7b68401D7B-DBF2-459F-92FF-669B0192074D%7d&Item=14&ID=2&Web=/programs

    Thanks, Lola

  7. MuraliKrishna says:

    Hi Guys,

    My Requirement is: I have an page it's coming from _Layouts,that page contains one Template Picker Control(share point control).so it showing all site templates like Team site,Wiki site etc.

    But My Issue is i have site template id like "STS#1" Now i need to show  this site template in  Template Picker Control using c# or Object model code.how to do that right know it selected  Default site template.

    Now I am using Javascript for the above task

    using GetWebTemplate('1033&Meetings','');

    using the above code I'm able to set the tab 'meetings'

    But How would I select a particular template under the meeting Tab.

    Thanks in Advance

    Muralikrishna.T

Skip to main content