Wednesday, May 2, 2007

Adding the bulk of Your Site Using Features

To add content to your Sharepoint site using features you need to create a feature.xml file or include the following elements into an existing elements.xml file.

To add content you make use of the Module element.


<Module Name="MainMasterPages"
Path="Masterpages"
Url="_catalogs/masterpage"
RootWebOnly="TRUE"></Module>

In the module element you give it a name attribute that will help you identify different modules. The Path attribute is the location of the files to upload in relation to the elements.xml file. The URL attribute is the URL on the Sharepoint site that you want the files to go. The RootWebOnly attribute is used to say if the file should only be available to the root web. Most of the time you can leave this true.

Within the Module element you place File elements that specify the actual files to upload to Sharepoint.


<File Url="main.master"
Type="GhostableInLibrary">
<Property Name="ContentType" Value="Landscape Master Page" />
<Property Name="Title" Value="Main Master Page" />
<Property Name="MasterPageDescription" Value="Master page for the home page." />
</File>

In the File element you specify the URL that you want the file to have in Sharepoint using the URL attribute. The Type attribute determines if the file will show up in the list or document library. If you set it to GhostableInLibrary then the file will show up. Inside the File elements you can place Property elements to provide additional information about the file. The property elements always consist of a name attribute that represents the name of the data and a value attribute that is the actual data.

In the example above we have a property called ContentType and it has a value that is the type of content that this file is, mainly a master page. The title property allows you to display the title that shows up in lists and when users can change the master page. The MasterPageDescription property allows you to provide a more detailed description of the file for users.

You can follow this same format to upload pretty much any type of content that you have. I have used it to upload master pages, style sheets, and images to the sites and folders that I wanted.

Following are some more links with more detailed information about uploading content:

http://www.andrewconnell.com/blog/archive/2006/12/20/5451.aspx

http://msdn2.microsoft.com/en-us/library/ms441170.aspx

Labels: , , ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home