3.7. Creating List Definitions Site definitions include definitions of the lists they contain. Creating a new list definition is more complex than creating a custom list template, so it is easiest if you start by copying an existing list definition, renaming, and modifying it. List definitions are found on the SharePoint server in the C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\TEMPLATE\1033\sitedef\LISTS folder, where sitedef is the folder containing the site definition. To create a new list definition in a site definition: -
Copy and rename the folder containing an existing list definition. -
Modify the list definition. The key file to edit is Schema.xml . -
Edit the site definition file ( ONet.xml ) to include the new list definition. -
Restart SharePoint by running iisreset.exe . -
View a site based on the site definition and create a list based on the new list definition to make sure it works. For example, to create a new list definition for the DotSites site definition: -
Copy the . \DotSites\LISTS\ANNOUNCEMENT folder and rename the new folder NewAnnouncements . -
Change the list definition Schema.xml file as summarized here: <?xml version="1.0" encoding="utf-8" ?> <List xmlns:ows="Microsoft SharePoint" Name=" NewAnnouncements " Title=" New Announcements " Direction="0" Url=" Lists/NewAnnouncements " BaseType="0" > <MetaData> <Fields> <Field Type="Note" RichText="FALSE" Name="Author" DisplayName="Author" Sortable="TRUE" > </Field> <Field Type="Note" RichText="TRUE" Name="Body" DisplayName="Body" Sortable="FALSE" > </Field> <Field Type="DateTime" Name="Expires" DisplayName="Expires" Format="DateOnly" FromBaseType="TRUE" > </Field> </Fields> <Views> ... </Views> <Forms> ... </Forms> <DefaultDescription> This is a demo showing how to create new list definitions. </DefaultDescription> <Toolbar Type="RelatedTasks"> ... </Toolbar> </MetaData> <Data> <Rows> <Row> ... </Row> </Rows> </Data> </List> -
Edit ONet.xml in . \DotSites\XML to include the new list definition. The changes are made in several places, as shown by the following snippet: <?xml version="1.0" encoding="utf-8" ?> <Project Title="Team Web Site" ListDir="Lists" xmlns:ows="Microsoft SharePoint"> ... <ListTemplates> ... <ListTemplate Name="NewAnnouncements" DisplayName="New Announcements" Type="204" BaseType="0" OnQuickLaunch="FALSE" SecurityBits="11" Description="" Image="/_layouts/images/itann.gif"> </ListTemplate> </ListTemplates> <Configurations> <Configuration ID="0" Name="Default"> <Lists> ... <List Title="New Announcements" Type="204" Url="Lists/NewAnnouncements" /> </Lists> </Configuration> </Configurations> ... </Project> -
Restart SharePoint. -
Open a test site based on the DotSites template and create a new list based on the list definition to make sure the changes worked. The new definition shows up on the Create page, as shown in Figure 3-14. animal 3-14. Testing a new list definition |