views:

16

answers:

1

Hi all,

I'm doing a site definition for SharePoint 2007. When the site is created, a document library called "Folder2" is created also. Now, I need to add some documents to this document library and appear as items in the document library standard views.

My code is:

<Lists>
    <List FeatureId="00bfea71-e717-4e80-aa17-d0c71b360101" Type="101" Title="Folder2" Url="Folder2">
        <Data>
            <Rows>
                <Row>
                    <Field Name="Name">MyFile.txt</Field>
                    <Field Name="Title">MyFile.txt</Field>
                    <Field Name="FileLeafRef">MyFile.txt</Field>
                </Row>
            </Rows>
        </Data>
    </List>
  </Lists>

When I see the items of the Document Library there is one element with title "1_". Does anybody know how to add files in a site definition?

The onet.xml I used is the same as blank site.

Thanks!!!

A: 

For Document Libraries, instead of Data/Rows/Row, use Modules:

<Lists>  
    <List FeatureId="00bfea71-e717-4e80-aa17-d0c71b360101" Type="101" Title="Folder2" Url="Folder2" />  
</Lists> 
<Modules>  
    <Module Name="Documents" />  
</Modules> 

Then in Modules at the bottom of onet.xml, you can define your Module as follows:

<Module Name="Documents" Url="Folder2" Path="">
    <File Url="MyFile.txt" Name="MyFile.txt" Type="GhostableInLibrary">
        <Property Name="Title" Value="MyFile.txt" />
    </File>
</Module>
Rich Bennema

related questions