Il modo più semplice per creare un template di lista per SharePoint 2007 (WSS3 - MOSS) e quello di partire da uno esistente e modificarlo.

I passi da seguire sono 6:
  • creare la cartella SgartListTemplate in 12\TEMPLATE\FEATURES
  • creare il file feature.xml in 12\TEMPLATE\FEATURES\SgartListTemplate
  • creare il file elements.xml in 12\TEMPLATE\FEATURES\SgartListTemplate\ListTemplates
  • creare il file schema.xml in 12\TEMPLATE\FEATURES\SgartListTemplate\Lista
  • installare la feature (vedi Come creare un file di solution (.wsp))
  • riavvia IIS (iisreset)
XML: feature.xml
<?xml version="1.0" encoding="utf-8"?>
<Feature Id="FDCDE3DE-19A3-43f7-BA9D-C9CA14176BAD"
    Title="Sgart - List"
    Description="Sgart - Feature con un esempio di template di lista"
    Version="1.0.0.0"
    Scope="Web"
    Hidden="FALSE"
    xmlns="http://schemas.microsoft.com/sharepoint/">
    <ElementManifests>
        <ElementManifest Location="ListTemplates\elements.xml"/>
    </ElementManifests>
</Feature>
l'attributo Id va valorizzato con un nuovo guid univoco per ogni feature

XML: elements.xml
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <ListTemplate
        Name="lista"
        Type="10500"
        BaseType="0"
        OnQuickLaunch="TRUE"
        SecurityBits="11"
        Sequence="1500"
        DisplayName="Sgart - List"
        Description="Sgart - Esempio di template di lista"
        Image="/_layouts/images/itcontct.gif"/>
</Elements>
da notare l'attributo Type è un identificativo univoco della lista, Sequence indica la posizione nella visualizzazione dell'elenco list e BaseType è il tipo base da cui deriva (0=Lista, 1=DocumentLibrary ...)

XML: schema.xml
<?xml version="1.0" encoding="utf-8"?>
<List xmlns:ows="Microsoft SharePoint" Title="Sgart List" Direction="0" FolderCreation="FALSE" Url="" BaseType="0" xmlns="http://schemas.microsoft.com/sharepoint/">
  <MetaData>
    <Fields>
      <Field ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title" DisplayName="$Resources:core,Last_Name;"
             Type="Text" Sealed="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Title" />
      <Field ID="{4a722dd4-d406-4356-93f9-2550b8f50dd0}" Name="FirstName" DisplayName="$Resources:core,First_Name;"
             Type="Text" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="FirstName" />

      <Field ID="{475c2610-c157-4b91-9e2d-6855031b3538}" Name="FullName" DisplayName="$Resources:core,Full_Name;"
             Type="Text" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="FullName" />
      <Field ID="{fce16b4c-fe53-4793-aaab-b4892e736d15}" Name="Email" DisplayName="$Resources:core,E-mail_Address;"
             Type="Text" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Email" />
    </Fields>
    <Views>
      <View BaseViewID="0" Type="HTML">
          <!-- copiare il codice da una lista esistente -->
      </View>
      <View BaseViewID="1" Type="HTML" WebPartZoneID="Main" DisplayName="All item" Url="AllItems.aspx" DefaultView="TRUE" SetupPath="pages\viewpage.aspx" ImageUrl="/_layouts/images/contacts.png" >
        <GroupByHeader>
          <!-- copiare il codice da una lista esistente -->
        </GroupByHeader>
        <GroupByFooter>
          <!-- copiare il codice da una lista esistente -->
        </GroupByFooter>
        <ViewHeader>
          <!-- copiare il codice da una lista esistente -->
        </ViewHeader>
        <ViewBody>
          <!-- copiare il codice da una lista esistente -->
        </ViewBody>
        <ViewFooter>
          <!-- copiare il codice da una lista esistente -->
        </ViewFooter>
        <PagedRowset>
          <!-- copiare il codice da una lista esistente -->
        </PagedRowset>
        <PagedClientCallbackRowset>
          <!-- copiare il codice da una lista esistente -->
        </PagedClientCallbackRowset>
        <PagedRecurrenceRowset>
          <!-- copiare il codice da una lista esistente -->
        </PagedRecurrenceRowset>
        <RowLimit Paged="TRUE">100</RowLimit>
        <ViewEmpty>
          <!-- copiare il codice da una lista esistente -->
        </ViewEmpty>
        <Toolbar Type="Standard" />
        <ViewFields>
          <FieldRef Name="Attachments" />
          <FieldRef Name="LinkTitle" />
          <FieldRef Name="FirstName" />
          <FieldRef Name="Email" />
        </ViewFields>
        <Query>
          <OrderBy>
            <FieldRef Name="Title">
            </FieldRef>
            <FieldRef Name="FirstName">
            </FieldRef>
          </OrderBy>
        </Query>
      </View>
    </Views>
    <Forms>
      <Form Type="DisplayForm" Url="DispForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
      <Form Type="EditForm" Url="EditForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
      <Form Type="NewForm" Url="NewForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
    </Forms>
  </MetaData>
</List>
Potrebbe interessarti anche: