For a current project I had to figure out how to place information in a list in SharePoint when you are creating a new site from a site template and place documents in a document library.
After a lot of searching on the internet I found some helpful stuff. Placing initial information in a list can also be found on the MSDN site.
First step is to create a new site definition. This can be done by copying an out of the box Template and adjusting it the way you would like it to be. More information about creating a site definition you can find at:
This can also be a helpful link:
The way for placing initial information in a SharePoint list is done by finding the right list in the onet.xml were in you would like to place the information.
For example you have to find a tag in your ONET.xml like the one below:
<!--List information--> <List FeatureId="1BFC6CD6-4941-4964-A143-25E62AAEF642" Type="107" Title="Taken" Url="Lists/Taken" QuickLaunchUrl="Lists/Taken/AllItems.aspx" ></List>
For placing information in that list you have to know the columns that that list uses and place it between the <list> and </list> with the <data> tag.
<!--Inserting initial information--> <List FeatureId="1BFC6CD6-4941-4964-A143-25E62AAEF642" Type="107" Title="Taken" Url="Lists/Taken" QuickLaunchUrl="Lists/Taken/AllItems.aspx" > <Data> <Rows> <Row> <Field Name="Title">Task 1</Field> </Row> <Row> <Field Name="Title">Task 2</Field> </Row> <Row> <Field Name="Title">Task 3</Field> </Row> <Row> <Field Name="Title">Task 4</Field> </Row> <Row> <Field Name="Title">Task 5</Field> </Row> </Rows> </Data> </List>
This example will place five new lines in the Task list with all different titles. If you would like to fill in more items for a task, you would just have to add more field items between a row tag. Placing documents into a site is done a little bit different.
For placing these documents in the right document library you have to add a folder to you site definition with a name you are just thinking off. For this example I choice the folder name doctemp. To place the documents into a document library you have to make a module in the onet.xml file. And add it to the right configuration.
WordDocuments is the name I created for my module. You have to specify the module at the end of the onet.xml between the <modules> tag just before the end tag of projects. The module you could enter there could be something like this:
<!--Inplementing module--> <Module Name="WordDocuments" List="101" Url="Documents" Path="docTemp"> <File Name="Test.doc" Url="Test.doc" Type="GhostableInLibrary" /> </Module>
The explanation of the used properties:
- Name: The name of the module.
- List: The list type of the list were you would like to insert the documents.
- Url: The URL to the list were you would like to insert the documents.
- Path: The path to the files
- File Name: The file name you would like to use.
- File Url: The file name you would like to insert.
- Type GhostableInLibrary: tells SharePoint to put an entry in the document library for this file, but this file will not be stored in the database it will stay on the file system.
So now you are ready to make a site template with initial information.