Creating Custom Columns
2.Create a Feature.xml in the MyCustomColumns folder.
<Feature
Id="E841E6DC-4056-4515-B407-F00276AB1CCA"
Title="MyCustomColumns"
Description="This Feature will create My Custom Columns"
Version="1.0.0.0"
Scope="Site"
Hidden="false"
ImageUrl="MySharepointProject\AfricanPith32.gif" xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest
Location="MyCustomColumns.xml" /> //Provide the path of the element manifest file which will contain the columns
</ElementManifests>
</Feature>
Id="E841E6DC-4056-4515-B407-F00276AB1CCA"
Title="MyCustomColumns"
Description="This Feature will create My Custom Columns"
Version="1.0.0.0"
Scope="Site"
Hidden="false"
ImageUrl="MySharepointProject\AfricanPith32.gif" xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest
Location="MyCustomColumns.xml" /> //Provide the path of the element manifest file which will contain the columns
</ElementManifests>
</Feature>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Field ID="{56F073C7-07E3-4df3-8ADF-F186EF74EC07}"
Name="AbstractText"
DisplayName="Abstract Text"
Group="Page Layout Columns" //define a group to put the columns into it
Type="Note" //Note means multiline text field
NumLines="10"
Required="TRUE">
</Field>
<Field ID="{F8C35ACB-61D4-4b6d-9FEA-DA010D704B46}"
Name="SourceText"
DisplayName="Source Text"
Group="Page Layout Columns"
Type="Text" //simple text field
Required="TRUE">
</Field>
<Field ID="{F8C35ACB-61D4-4b6d-9FEA-DA010D704B46}"
Name="SourceText"
DisplayName="Source Text"
Group="Page Layout Columns"
Type="Text" //simple text field
Required="TRUE">
</Field>
<Field ID="{E918A3F4-9E34-4bd2-A621-5F353B4529E2}"
Name="ArticleSubType"
DisplayName="Article Sub Type"
Type="Lookup" //Lookup type field
</Field>
<Field ID="{E918A3F4-9E34-4bd2-A621-5F353B4529E2}"
Name="ArticleSubType"
DisplayName="Article Sub Type"
Type="Lookup" //Lookup type field
Mult="TRUE" //True for Multi Lookup field
Required="FALSE"
List="F99AFCB4-4699-4AA1-BBE8-FEA3269175E6" //GUID of the Lookup List
List="F99AFCB4-4699-4AA1-BBE8-FEA3269175E6" //GUID of the Lookup List
ShowField="Title" //Field of the Lookup List which will be refered
UnlimitedLengthInDocumentLibrary="FALSE"
Group="Page Layout Columns"
/>
</Elements>
Activate this feature in Site collection level and the site columns will be created under the group Page Layout Columns.Group="Page Layout Columns"
/>
</Elements>
Note:
1.Need to create a Lookup List with the same GUID before activating this feature.
refer this link for creating custom list instance: create-list-instance-using-custom-list
Creating Custom Content Type
1.Create a folder MyCustomContentTypes under Feature folder in the project.2.Feature.xml in MyCustomContentTypes folder.
<Feature Id="1DA3D932-288E-4d10-856A-66F4DCF8D473"
Title="MyCustomContentTypes"
Description="This Feature will create My Custom ContentTypes"
Version="1.0.0.0"
Scope="Site"
Hidden="false"
ImageUrl="MySharepointProject\AfricanPith32.gif" xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest
Location="MyCustomContentTypes.xml" />
</ElementManifests>
<ActivationDependencies>
<!-- Installs the site columns feature before -->
<ActivationDependency FeatureId="E841E6DC-4056-4515-B407-F00276AB1CCA"/>
</ActivationDependencies>
</Feature>
3.Create MyCustomContentTypes.xml file at the same location.
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<ContentType ID="0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D0039F449FD09F64ed283F86980FE51CF92"
Name="My News Article Page"
Group="Page Layout Content Types"
Description="My Custom Page Layout Content Type"
Version="0"
Hidden="FALSE">
<FieldRefs> //Refer the fields created by custom columns feature
<FieldRef ID="{56F073C7-07E3-4df3-8ADF-F186EF74EC07}" Name="AbstractText"/>
<FieldRef ID="{F8C35ACB-61D4-4b6d-9FEA-DA010D704B46}" Name="SourceText"/>
<FieldRef ID="{E918A3F4-9E34-4bd2-A621-5F353B4529E2}" Name="ArticleSubType"/>
</FieldRefs>
</ContentType>
</Elements>
Note:
ID is the most important prperty of a content type.If you are inheriting a site content type,append 00 after the GUID of the site content type and then add a new GUID to create the ID for your content type. Here
0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D
is the GUID for article content type of sharepoint publishing portal and I have added 0039F449FD09F64ed283F86980FE51CF92 to create the ID for My News Article Page Content Type.
Activate this feature in Site collection level and the My News Article Page Content Type will be created in site content types with the following fields,where our custom columns will be present along with Article Page columns.

No comments:
Post a Comment