Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

This is in the context of MOSS 2007.

I have a custom site definition. Currently in ONET.xml we have the following Module:

<View List="$Resources:core,lists_Folder;/$Resources:core,announce_Folder;" BaseViewID="0" WebPartZoneID="Left" WebPartOrder="1" />

You'll notice that this is a site with the publishing features activated and the default.aspx page is provisioned to the Pages library. This correctly provisions the page to the Pages library with an Announcements List View web part provisioned to the page.

I have about 800 (or so) sites created from this site definition. We have a need to add a few web parts to the page for any new sites created from the template and also for all of the existing 800 sites.

The plan was to move the default.aspx module from ONET and into a feature, then reference the feature from ONET. Once this was done, generate a series of stsadm deactivatefeature and activatefeature commands to get the home page the way we needed for all existing sties. New sites would pick it up via the feature.

When I do this I can deactivate and reactivate the feature to correctly replace the home page with the "latest version". However, when I create new sites (for example using Central Admin or through the API using SPWebApplication.Sites.Add()), the site creation fails with a very generic "Cannot complete this action. Please try again." error message. Digging through the 12\Logs, I found a little more detail:

Failed to find a suitable list for tag in module for file 'Pages/default.aspx' given List attribute 'Lists/Announcements'.

If I take the element out of the , things work fine (but this obviously is not what I want). I've tried a number of things, such as replacing the "List='104'", trying with other list types, etc. All with same/similar result.

Do elements work when are provisioned to "Pages" library? Is there an a way to get this to work correctly? Is there a suitable workaround to allow me to configure my site definition to create the correct web parts for existing sites and any new sites?

share|improve this question
    
More Info: I just wired up a feature receiver to my new "home page feature" and set a breakpoint on feature activated. I walked through the SPWeb.Lists and the Announcements list doesn't exist. The list is provisioned in ONET. Does SharePoint do feature activation before any list provisioning in ONET? –  Brian May 28 '10 at 3:08
    
Brian, it is NOT supported to change the ONET.xml once a site has been created of it. Usually it's ok, but I've seen weird things happen because of it! In SP2010, this is supported by using the new WebTemplate feature element. –  Colin Jun 15 '11 at 10:44
    
P.S. More info on this here:blogs.msdn.com/b/vesku/archive/2010/10/14/… –  Colin Jun 15 '11 at 10:47
add comment

1 Answer 1

Well, given enough time, you can figure things out with SharePoint...

Here is what appears to be happening.

In ONET, I also had CAML to provision some lists (here is the Announcements one):

 <List FeatureId="00BFEA71-D1CE-42de-9C63-A44004CE0104" Type="104" Title="$Resources:core,announceList;" Url="$Resources:core,lists_Folder;/$Resources:core,announce_Folder;">
      <Data>
        <Rows>
          <Row>
            <Field Name="Title">Something</Field>
            <Field Name="Body">Here</Field>
            <Field Name="Expires">&lt;ows:TodayISO/&gt;</Field>
          </Row>
        </Rows>
      </Data>
    </List>

I guess that SharePoint must activate all features in ONET's and BEFORE it does anything else in ONET (like provision lists and modules). So, if I had my default.aspx page in it was getting activated BEFORE my list(s) were provisioned. Hence my error message about trying to provision a List View web part using a list that didn't yet exist. I guess this makes sense since you could have a Feature in SiteFeatures or WebFeatures that is needed to make a list, or provision a Module.

My solution:

Move the List elements from ONET to ListInstance elements in a new feature. I had setup a feature ActivationDependency on my new Pages feature to the new Lists feature, but that resulted in my list data being provisioned on existing items when i reactivated the Pages feature. I stripped the ActivationDependency, and just ensured that Lists feature reference appears before Pages feature reference in ONET.

SharePoint always keeps it interesting!

share|improve this answer
    
thanks for this! –  tarjeieo Nov 7 '11 at 15:44
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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