Question from a forum post

Question from a forum post at http://www.sharepointu.com/forums/p/4055/10709.aspx:

When creating a site template, is there a way to name a set of lists and/or document libraries based on the name of the site that is chosen when creating a new site based on a custom site template? For example, creating a new site called “Peter Pan” and then having the list and doc library (in the template) named “Peter Pan List” and “Peter Pan Doc Library” automatically after creation of the site.

/End question

Answer:
You can do this relativly easy in a featureactivated event handler, but it does require a bit of coding and provisioning the lists or sites as features or site definitions. If programming is ok with you and you are able to work with the SharePoint OM, you would go about this in one of two ways.

First you can provision the site as a site definition and have a webfeature or sitefeature that has an event handler to rename the lists. Doing this the feature way can in turn be done in one of two ways. First, you can have a ‘rename lists’ feature that renames lists when the feature is activated through the site definition. One downside to this is that any future lists added will not be renamed. One upside, amongst others, is that you can rename lists regardless of the lists themselves, that is, any list, regardless of how that list is provisioned through the site definition, can be renamed. The other way to do this features based is to add all lists as features and have the event handlers attached to those features. The downside is that you wont be using the ‘Create’ option of the site actions or view all site content page. The upside is that you can do this also after the site has been provisioned so that all new lists will be named accordingly.

The other option for renaming lists is to use a little known site provisioning object model. This technique is used by the collaboration portal in MOSS, but is available to WSS if you are willing to walk the coding lines. Again, this only works when you are provisioning sites, not for creating lists after the fact. To do this you would use the ProvisionData, ProvisionAssembly and ProvisionClass as attributes to your site definition in webtemp*.xml. If you want to go down this route, and it may be usefull anyways if only for the exercise, Anders Jacobsen has written a short article that gets you started:
http://www.pings.dk/blog/archive/2007/10/18/create-a-web-provisioner-to-enable-quote-post-site-creation-actions-quote.aspx

The huge benefit of the latter option, using the SPWebProvisioningProvider, is the flexibility you get from having complete programmatic access to site provisioning. You can add users, create on-the-fly lists, build workflows and connect them to content types or lists based on any criteria (how about appending I HATE MONDAYS to all items on a site created on Monday mornings?) or basically anything else you can do to a site. Best, or worst, part is, you dont even need a site definition outside the webtemp*.xml, you can create your entire site inside code. In fact, this is what the collaboration portal does, you will not find a SPSPORTAL site definition anywhere, but rather a reference to an assembly that does the entire provisioning through code.

Good luck!

.b

Found this article valuable? Want to show your appreciation? Here are some options:

a) Click on the banners anywhere on the site to visit my blog's sponsors. They are all hand-picked and are selected based on providing great products and services to the SharePoint community.

b) Donate Bitcoins! I love Bitcoins, and you can donate if you'd like by clicking the button below.

c) Spread the word! Below, you should find links to sharing this article on your favorite social media sites. I'm an attention junkie, so sharing is caring in my book!

Pin It

Published by

Bjørn Furuknap

I previously did SharePoint. These days, I try new things to see where I can find the passion. If you have great ideas, cool projects, or is in general an awesome person, get in touch and we might find out together.

3 thoughts on “Question from a forum post”

  1. Hi dude,
    Question:
    I have custom workflows for a SharePoint custom list.
    The workflows are not triggered for reason unknown even though I checked the “Automatically start options for every item that is added / changed” in the SharePoint designer.
    The workflows work fine when it is “set to manual option”
    I have recently installed the SP1.
    The following resolution option does not work for me..
    http://wsswiki.com/KB947284
    Any ideas!

  2. first order of business is to check all logs. Check event log, both system and application. Second, check SharePoint logs, at {12 hive}\Logs.

    There may not be anything there, depending on what you have set up in your diagnostics logging. To resolve this issue you may want to modify those settings. That is done in Operations on the Central Administration site.

    My recommended settings here is to set everything in the Workflow Infrastructure to verbose logging and use a tool like LogViewer, available from CodePlex at http://www.codeplex.com/features

    Try your workflow again and see if anything shows up in any of the logs. If not, let me know and I will try to help you further.

    In any case, let me know how it turns out 🙂

    Good luck!

    .b

  3. I’m very sorry for posting inappropriately.. I wasn able to locate an option for that.
    I have a question.

    I want to add few options with already existing web part and customize it more using sharepoint designer.

    I do not get the needed options through browser customizations.

    Is it possible?.. How can i open a particular web part in SharePoint designer?
    Its a discussion board. We need to add a tab along with the existing options.

    The aspx page has this web part in placeholder main

    Thanks for reply..

Leave a Reply

Your email address will not be published.