Deploy di un Content Type tramite Feature
In SharePoint 2010 per deployare un content type con relativi campi è necessario creare una feature con i seguenti file:
File: Elements.xml
File: Feature.xml
File: Elements.xml
XML
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<!-- **** prima definisco i campi a livello di site collection **** -->
<Field ID="{c9f55776-e09f-4e8c-b3c2-efc314c22909}" Name="SgartSubTitle" DisplayName="Sub Title" Type="Text"
Required="FALSE" EnforceUniqueValues="FALSE" Indexed="FALSE" MaxLength="255" Group="Sgart" />
<Field ID="{00db0469-d6f5-4f80-baf7-9a69d39d30fc}" Name="SgartRating" DisplayName="Rating" Type="Choice"
Required="TRUE" EnforceUniqueValues="FALSE" Indexed="FALSE" Format="Dropdown" FillInChoice="FALSE" Group="Sgart"
Hidden="FALSE" ReadOnly="FALSE" >
<Default>5</Default>
<CHOICES>
<CHOICE>3</CHOICE>
<CHOICE>4</CHOICE>
<CHOICE>5</CHOICE>
<CHOICE>6</CHOICE>
<CHOICE>7</CHOICE>
<CHOICE>8</CHOICE>
<CHOICE>9</CHOICE>
<CHOICE>10</CHOICE>
</CHOICES>
</Field>
<Field ID="{05103b26-e10f-4d6f-8b14-ced3e75cbe64}" Name="SgartEnable" DisplayName="Enable" Type="Boolean"
EnforceUniqueValues="FALSE" Indexed="FALSE" Group="Sgart" Required="FALSE">
<Default>0</Default>
</Field>
<Field ID="{0f0ddfdf-94e2-4ba9-bd73-c27633e98b7d}" Name="SgartRepliesNumber" DisplayName="Replies Number" Type="Number"
Required="FALSE" EnforceUniqueValues="FALSE" Indexed="FALSE" Decimals="0" Group="Sgart"
Percentage="FALSE" Hidden="FALSE" ReadOnly="FALSE" >
<Default>0</Default>
</Field>
<Field ID="{16814f11-a5e0-4e22-8f78-7a15b2e1c3b4}" Name="SgartUsersReply" DisplayName="Users Reply" Type="UserMulti"
List="UserInfo" Description="utenti che hanno risposto" Required="FALSE" EnforceUniqueValues="FALSE" ShowField="ImnName"
UserSelectionMode="PeopleOnly" UserSelectionScope="0" Mult="TRUE" Sortable="FALSE" Group="Sgart" />
<Field ID="{8962e426-b873-4e19-8f1e-dc67d8b69906}" Name="SgartQuestionsXML" DisplayName="MyXML" Type="Note"
Required="FALSE" EnforceUniqueValues="FALSE" Indexed="FALSE" NumLines="6" RichText="FALSE" Sortable="FALSE" Group="Sgart" />
<!-- **** poi definisco i content types **** -->
<ContentType ID="0x010068ECA9A1B15244179CA54678D460D2E0"
Name="SgartCT"
Group="Sgart"
Description="">
<FieldRefs>
<FieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title" DisplayName="Title" Required="TRUE" Sealed="TRUE"/>
<FieldRef ID="{c9f55776-e09f-4e8c-b3c2-efc314c22909}" Name="SgartSubTitle" />
<FieldRef ID="{00db0469-d6f5-4f80-baf7-9a69d39d30fc}" Name="SgartRating" DisplayName="Rating" Required="TRUE" />
<FieldRef ID="{05103b26-e10f-4d6f-8b14-ced3e75cbe64}" Name="SgartEnable" DisplayName="Enable" ShowInNewForm="false"/>
<FieldRef ID="{0f0ddfdf-94e2-4ba9-bd73-c27633e98b7d}" Name="SgartRepliesNumber" DisplayName="Replies Number" ShowInEditForm="false" ShowInNewForm="false" />
<FieldRef ID="{16814f11-a5e0-4e22-8f78-7a15b2e1c3b4}" Name="SgartUsersReply" DisplayName="Users Reply" ShowInNewForm="false" />
<FieldRef ID="{8962e426-b873-4e19-8f1e-dc67d8b69906}" Name="SgartQuestionsXML" DisplayName="XML" ShowInEditForm="false" ShowInNewForm="false" />
</FieldRefs>
</Elements>
File: Feature.xml
XML
<?xml version="1.0" encoding="utf-8"?>
<Feature xmlns="http://schemas.microsoft.com/sharepoint/"
Id="45a2cefa-d54b-42a4-9fa6-56a8edd2ca95"
Title="Sgart - Content Type"
Scope="Site"
Description=""
ImageUrl="Sgart/feature.png"
>
<ElementManifests>
<ElementManifest Location="Elements.xml" />
</ElementManifests>
</Feature>