I've moved my blog to!. Please update your links. This blog is no longer in use--you can find all posts and comments at my new blog; I will no longer be posting to this site and comments have been disabled.

Thursday, August 9, 2007

Site Collection Title

9/17/2007: This command has been made obsolete and removed from the package. Please use gl-setsitegeneralsettings instead. Sorry for any inconvenience this may have caused.

This is one of those that I thought I needed because during the upgrade the mysites application got hosed so was expecting to have to set the title manually. It turns out that the gradual upgrade screwed up everything related to our personal sites and profile database so our solution ended up being to delete the upgraded SSP and create a new one via scripts. This ended up negating the need to set the titles but I already had the code so I figured I'd document it anyways. You can set the title manually by going to any site collection's site settings and clicking the "Title, Description and Icon" link. Or you can do it programmatically by setting the Tile property of the SPWeb object (which you get from an SPSite object) as shown below:

   1: string url = keyValues["url"];
   2: string title = keyValues["title"];
   4: using (SPSite siteCollection = new SPSite(url))
   5: {
   6:  using (SPWeb site = siteCollection.AllWebs[""])
   7:  {
   8:   site.Title = title;
   9:   site.Update();
  10:  }
  11: }

The syntax of the command I created to do this can be seen below.

C:\>stsadm -help gl-setsitecollectiontitle

stsadm -o gl-setsitecollectiontitle

Sets the title of a site collection.

        -url <site collection>
        -title <title>

Here’s an example of how to set the site collection title:

stsadm –o gl-setsitecollectiontitle –url “http://intranet/” –title "Corporate Portal"

No comments: