Section 3.7. Creating List Definitions


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:

  1. Copy and rename the folder containing an existing list definition.

  2. Modify the list definition. The key file to edit is Schema.xml .

  3. Edit the site definition file ( ONet.xml ) to include the new list definition.

  4. Restart SharePoint by running iisreset.exe .

  5. 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:

  1. Copy the . \DotSites\LISTS\ANNOUNCEMENT folder and rename the new folder NewAnnouncements .

  2. 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> 

  3. 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> 

  4. Restart SharePoint.

  5. 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



Essential SharePoint
Essential SharePoint 2007: A Practical Guide for Users, Administrators and Developers
ISBN: 0596514077
EAN: 2147483647
Year: 2005
Pages: 153
Authors: Jeff Webb

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net