Type contentType = typeof(SPContentType);
Type paramType = typeof(SPContentTypeId);
Type[] paramArray = { paramType };
ConstructorInfo consInfo = contentType.GetConstructor(BindingFlags.Instance BindingFlags.NonPublic, null, CallingConventions.Any, paramArray, null);
object[] paramsX = { new SPContentTypeId(contentTypeID) };
SPContentType contentTypeObject = consInfo.Invoke(paramsX) as SPContentType; contentTypeObject.GetType().InvokeMember("Web", BindingFlags.NonPublic BindingFlags.Instance BindingFlags.SetProperty BindingFlags.IgnoreCase, null, contentTypeObject, new object[] { targetWeb }); contentTypeObject.GetType().InvokeMember("Collection", BindingFlags.NonPublic BindingFlags.Instance BindingFlags.SetProperty BindingFlags.IgnoreCase, null, contentTypeObject, new object[] { targetWeb.ContentTypes }); return contentTypeObject;
Showing posts with label Creating Feature. Show all posts
Showing posts with label Creating Feature. Show all posts
Wednesday, July 22, 2009
Friday, July 3, 2009
Site Coloumn As Feature
How To Create a Feature
As a first step you you have to add a subfolder containing a Feature definition(Feature.xml) within the Features setup directory (Local_Drive:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES). Feature.xml file defines the base properties of the Feature and lists elements bound to it. The Feature element is used in a Feature.xml file to define a Feature and to specify the location of assemblies, files, dependencies, or properties that support the Feature
Create a Site Coloumn Feature
1. Create a new folder called "SampleBlogColoumn" under C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\Template\Features\.
2.Create a new file called features.xml containing:
<Feature Id="F5E3FEE8-1D9B-4b95-848B-7614D638B90D" Title="Sample Bloge Site Columns" xmlns="http://schemas.microsoft.com/sharepoint/" Description="Shyju mohan's Sample Site Columns" version="1.0.0.0" scope="Site" hidden="FALSE">
<ElementManifests>
<ElementManifest Location="elements.xml">
</ElementManifests>
</Feature>
This feature.xml will describe about our new site column feature.This file should be placed in the folder created in previous step.
3. Create a new file called elements.xml
<?xml version="1.0" encoding="utf8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Field ID ={94EF4E88-A8AE-4b11-8110-DEE7B2CE4D41} Name="PersonName"
SourceID="{9c8a1ac8-fe75-4d7d-87af-e1de3e1b82e6}" StaticName="PersonName" Group="BlogSample"
Type="Text" DisplayName="Person Name"/>
<Field ID ={95EF4E88-A8AE-4b11-8110-DEE7B2CE4D41} Name="Age"
SourceID="{9c8a1ac8-fe75-4d7d-87af-e1de3e1b82e6}" StaticName="Age" Group="BlogSample"
Type="Text" DisplayName="Age"/>
<Field ID ={96EF4E88-A8AE-4b11-8110-DEE7B2CE4D41} Name="Salary"
SourceID="{9c8a1ac8-fe75-4d7d-87af-e1de3e1b82e6}" StaticName="Salary" Group="BlogSample"
Type="Number" DisplayName="Salary"/>
</Elements>
This element.xml will describe each coloumn in our feature.This file should be placed in the folder created in previous step.Now we are ready to deploy our feature.Assumes already know about the tool STSADM (Exe tool runs from the command propmpt).We can use stsadm to deploy our feature
4. Open a command prompt and type the following:
CD C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\bin
stsadm -o installfeature -file SampleBlogColoumn
Above command will install the feature.Next step is to activate the feature so we can go for command prompt again or sharepoint central administration site to activate the feature.
5.Again in command prompt and type the following:
stsadm -o activatefeature -file SampleBlogColoumn -url http://localhost/
Further Reading Content Type as Feature
Cheers
Shyju Mohan
Create ContentType as a Feature
Some times it will be necessary to deploy contenttype as a feature.If you are new to ContentType then follow my previous POST.
How To Create a Feature
As a first step you you have to add a subfolder containing a Feature definition(Feature.xml) within the Features setup directory (Local_Drive:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES). Feature.xml file defines the base properties of the Feature and lists elements bound to it. The Feature element is used in a Feature.xml file to define a Feature and to specify the location of assemblies, files, dependencies, or properties that support the Feature
Create a ContentType Feature
First step create the desired coloumn as a feature Follw My BlogCreate Site Coloumn As Feature
1. Create a new folder called "SampleBlogContetType" under C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\Template\Features\.
2.Create a new file called features.xml containing:
3. Create a new file called elements.xml
<?xml version="1.0" encoding="utf8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<ContentType ID ="0x0110035A5E402D9B4EAAC0049A3554D81" Name="BlogPerson"
Version='1' Group="BlogSample"/>
<FieldRefs>
<FieldRef ID ="{95EF4E88-A8AE-4b11-8110-DEE7B2CE4D41}" Name="PersonName"/>
<FieldRef ID ="{95EF4E88-A8AE-4b11-8110-DEE7B2CE4D41}" Name="Age"/>
<FieldRef ID ="{96EF4E88-A8AE-4b11-8110-DEE7B2CE4D41}" Name="Salary"/>
</FieldRefs>
</ContentType>
</Elements>
4. Open a command prompt and type the following:
CD C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\bin
stsadm -o installfeature -file SampleBlogContetType
5.Again in command prompt and type the following:
stsadm -o activatefeature -file SampleBlogContetType -url http://localhost/
Cheers
Shyju Mohan
How To Create a Feature
As a first step you you have to add a subfolder containing a Feature definition(Feature.xml) within the Features setup directory (Local_Drive:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES). Feature.xml file defines the base properties of the Feature and lists elements bound to it. The Feature element is used in a Feature.xml file to define a Feature and to specify the location of assemblies, files, dependencies, or properties that support the Feature
Create a ContentType Feature
First step create the desired coloumn as a feature Follw My BlogCreate Site Coloumn As Feature
1. Create a new folder called "SampleBlogContetType" under C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\Template\Features\.
2.Create a new file called features.xml containing:
<Feature Id="3B4752E6-8D62-4df0-A4D3-31C8E99D44FC" Title="Blog Sample Content Type" xmlns="http://schemas.microsoft.com/sharepoint/" Description="Shyju Mohan's Sample Content Type" version="1.0.0.0" scope="Site" hidden="FALSE">
<ElementManifests>
<ElementManifest Location="elements.xml">
</ElementManifests>
</Feature>
3. Create a new file called elements.xml
<?xml version="1.0" encoding="utf8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<ContentType ID ="0x0110035A5E402D9B4EAAC0049A3554D81" Name="BlogPerson"
Version='1' Group="BlogSample"/>
<FieldRefs>
<FieldRef ID ="{95EF4E88-A8AE-4b11-8110-DEE7B2CE4D41}" Name="PersonName"/>
<FieldRef ID ="{95EF4E88-A8AE-4b11-8110-DEE7B2CE4D41}" Name="Age"/>
<FieldRef ID ="{96EF4E88-A8AE-4b11-8110-DEE7B2CE4D41}" Name="Salary"/>
</FieldRefs>
</ContentType>
</Elements>
4. Open a command prompt and type the following:
CD C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\bin
stsadm -o installfeature -file SampleBlogContetType
5.Again in command prompt and type the following:
stsadm -o activatefeature -file SampleBlogContetType -url http://localhost/
Cheers
Shyju Mohan
Subscribe to:
Posts (Atom)