Sharpoint 2010 Creating a site template with Visual Studio

Source: Internet
Author: User

Here I do a simple example to explain the creation of the following site templates, there are mainly 2 main concerns, one is the Web site customization (sitedefinition), and the other is the check-in of the master page (masterpage). As for the other extensions, look at their own skill. This method is also appropriate for SharePoint 2013.

Development SP2010, I used to use VS2010 before, I used to be VS2010 Chinese flagship version, it is a pity that this version does not have the elements of the site definition, need to download third-party plug-ins or something, anyway, I have not tried, interested can study on their own. The version I use in the following example is the VS2013 Chinese flagship version.

1 First create a SharePoint 2010 Empty Project

2 Selecting a farm solution

3 An empty SP2010 solution is generated at this time

4 we add the master page first, add the method: Right-click Add New Item, select "Module",

5 upon completion, as

6 Now we do a little change, first nested two-layer folder corresponding to the location of the master page, and then change "Sample.txt" to Sample.master, and then dragged into the lowest folder. This allows the custom master page to be built. Such as:

7 Open its Elements.xml, modify the URL, as follows:

<?XML version= "1.0" encoding= "Utf-8"?><Elementsxmlns= "http://schemas.microsoft.com/sharepoint/">  <ModuleName= "Module1">    <FilePath= "Module1\_catalogs\masterpage\sample.master"URL= "_catalogs/masterpage/sample.master" />  </Module></Elements>

8 now open a Web site with the designer, copy the V4 master page code, put in just new sample master page, as for the master page design, I will not say, in order to distinguish V4, I set its background color is red;

<scroll= "No"  style= "background-color:red"

9 Now that the master page is complete, we want to create the site definition, right-click the project to add New item, select site definition such as:

10 open "ONET.xml" and do the following configuration

<?XML version= "1.0" encoding= "Utf-8"?><ProjectTitle= "SiteDefinition1"Revision= "2"Listdir=""xmlns:ows= "Microsoft SharePoint"xmlns= "http://schemas.microsoft.com/sharepoint/">  <Navbars>  </Navbars>  <configurations>    <ConfigurationID= "0"Name= "SiteDefinition1"MasterUrl= "_catalogs/masterpage/v4.master"Note: Default master page CustomMasterUrl= "_catalogs/masterpage/sample.master" >notes: Customizing Master Pages<Lists/>      <Sitefeatures>      </Sitefeatures>      <WebFeatures>        <FeatureID= "A35A1ADF-3B4B-46F0-8159-1CA43A06BC56"></Feature>Note: Register for Feature1; ID in the Feature1 list (no need to care about its XML), if the scope is site, this paragraph is written in<Sitefeatures>in</WebFeatures>      <Modules>        <ModuleName= "Defaultblank" />      </Modules>    </Configuration>  </configurations>  <Modules>    <ModuleName= "Defaultblank"URL=""Path="">      <FileURL= "default.aspx">      </File>    </Module>  </Modules></Project>

11 open "Webtemp_sitedefinition1.xml" to define site model properties

<?XML version= "1.0" encoding= "Utf-8"?><Templatesxmlns:ows= "Microsoft SharePoint">  <TemplateName= "SiteDefinition1"ID= "10000">    <ConfigurationID= "0"Title= "My custom site template"Hidden= "FALSE"IMAGEURL= "/_layouts/images/cpvw.gif"Description= "My Site template description: I really can't fly"displaycategory= "Category: Cannot Fly">    </Configuration>  </Template></Templates>

12 Open "Default.aspx" modify, reference custom master page

<% @ Page Language = " C # " MasterPageFile = " ~masterurl/custom.master "

13 Deploy the project now, then go to central Administration, create a site collection

14 page below, the background is red, we define the new master page

15 Open Designer, you can see that the new master page has been added to the specified directory

Now the site template creation has been introduced, thank you for your reading. Share Unlimited, share happiness!

Sharpoint 2010 Creating a site template with Visual Studio

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.