One of the benefits of sharepoint2010 is that it greatly improves the feature version management capability. We can use visual studio2010 to control and upgrade the developed feature versions. Content type is used as an example to demonstrate the version control and upgrade functions of content type feature.
What we need to do in this article is to use vs2010 to develop a feature, assign it a version number and deploy it on our website. The next article describes how to modify and upgrade this feature. The procedure is as follows:
1. Use Visual studio2010 to create an empty SharePoint Project ("Empty SharePoint project") and name it "testupgradablect ". This farm solution associates this project with your own test website address. here our test website is:
Http: // sd1-sp1dev: 2100/sites/sptestsite
Specify farm or sandbox
2. Add a new content type item to the project testupgradablect. Name it "The upgradeable content type ",
The development environment will pop out a window asking you to specify the parent type of this content type item and select "document"
Vs2010 will add the upgradable content type item to your project and open its element. XML content, such:
3. Modify element. XML as follows:
<? XML version = "1.0" encoding = "UTF-8" ?>
< Elements Xmlns = "Http://schemas.microsoft.com/sharepoint" >
< Contenttype ID = "0x0101000dca415159f044bba9feb7f6d1abad4c"
Name = "Zlupgradeablect"
Group = "A feature Upgrade Attempt"
Description = "The upgradeable content type"
Version = "0" >
< Fieldrefs >
< Fieldref ID = "{8c8d6c5e-f9ab-4b48-86b1-0126fab%f4 }" />
</ Fieldrefs >
</ Contenttype >
< Field ID = "{8c8d6c5e-f9ab-4b48-86b1-0126fab%f4 }"
Name = "Note1"
Staticname = "Note1"
Displayname = "Note on version 1"
Type = "NOTE"
Group = "A feature Upgrade Attempt" >
</ Field >
</ Elements >
This step adds a field to the content type we just created. This field is of the Note type. Here we have set the attributes of this field (name, staticname, displayname, group), and reference it to our contenttype through the <fieldrefs> section. The field ID can be generated using tools> Create guid in vs2010. The Group attribute specifies the group to which the contenttype we created belongs. We will use it later to quickly locate our contenttype.
4. Modify the feature version of the project.
Double-click your feature node and change its version to 1.0.0.0. This column is empty by default, which means the default version is 0.0.0.0.
Then build and deploy the project.
5. view results
Open our website and we are going to test the shared documents of this website.
Click shared docuemets and select library --- library settings of library tools.
Click to go to the advanced setting page and set allow management of content types to yes.
After setting, you can view the content types column on the document library settings page,
Select Add from existing site content types to go to the select content types settings page. In the group drop-down box on this page, select a feature upgrade attempt, here we can see the content type we just developed with vs2010. Its name is "zlupgradeablect", which is directly added to the list box on the right.
Return to our shared documents to add a new document for it. At this point, we can see that the content type we created is more
Open the new document and you can see that it does work. You must enter the relevant content for the new document.
After saving, the Add document window is opened through the Add document function. This window shows the content we entered when creating a new document.
You can see the result after saving it.