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 Content Type. Show all posts
Showing posts with label Content Type. Show all posts
Wednesday, July 22, 2009
Friday, July 3, 2009
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)