I'm looking for a way of AUTOMATICALLY adding an item to a list on a root-site when you create a new subsite of a specific type.

Context: I'm building a "Project Portal", and there's a requirement for a dashboard type webpart that displays [ALL], [OPEN] and [CLOSED] projects. Each project has it's own subsite (built from a custom site-template) and also has a status-indicator to show the progress of the project.

The easiest thing I could think of, was a custom list on the root-site, which contained a listitem per project (subsite), with one of the columns being a lookup value to that project's status indicator. That way I could just make views, filtering on that status indicator. But how would I make this list? Is it possible without custom code?

The only way I can think of, is creating an event handler, when a new site is created, check if it's the right template being used (can you even accomplish this?) and then using code create the list item. Is this a solution? and is it the only one?

3 Answers 3


There is no way without custom code. But what I'd do was:

  • Create a web-scoped feature which in the FeatureActivated event in the FeatureReceiver added the item to the list in to Site collection RootWeb
  • Make the feature hidden
  • Include the feature in the <WebFeatures> section of the custom templates onet.xml
  • I like that idea - the other answer I got on technet was a list with an added item event handler, that creates the subsite - so you'd essentially be using the list as creation for the projects. I like this better, as it doesn't force users to use the list! Thanks, I'm gonna try to implement it, and mark as answer if it fits :)
    – Dynde
    Apr 11, 2012 at 10:23

You can indeed fire an event when a new site is created and check the template (SPWeb.WebTemplateId)

You would make a farm-scoped, webapp-scoped or site-scoped feature and leverage the WebProvisioned event (which triggers every time any web is created on that scope).

It's very much equivalent to Per's method. In fact since you are using a custom site definition I would probably go with the web-scoped feature linked to that definition.

  • Thank you! Two good suggestions. I'm gonna test both, and see which fits the profile and the user interactions better.
    – Dynde
    Apr 11, 2012 at 10:42

I chose a 3rd route, just wanted to share my final decision, if anyone finds it helpful.

I opted to make a webpart that simply makes use of SPSiteDataQuery. This query searches subsites for lists called "Project Status", which is a status list. Alle project/subsites have this list, and have only a single status indicator (Project Status), which the webparts fetches for each of the subsites, and displays them in the webpart.

In order to make the filtering I chose to make a jQuery tabpanel, with three tabs [All], [Open] and [Closed], and each tab contained a simple bullet list of links to the subsites - filtered and fed from the Page_Load event.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.