Back to the Features - Element.xml
In this installment of features we will look at the Element.xml file (or whatever you called it). This is the file that does the actual work in a feature. An example file might look like this:
<?xml version="1.0" encoding="utf-8" ?>
<elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="ViewPhotoPage"
Path="Pages"
Url="Pages"
RootWebOnly="FALSE">
<File Url="viewphoto.aspx"
Type="GhostableInLibrary">
<property name="Title" value="View Photo">
<property name="Description" value="The view photo page.">
</file>
</module>
<Module Name="Images"
Url="PublishingImages"
Path="images"
RootWebOnly="TRUE">
<file url="LFILogo_NoByline.gif" type="GhostableInLibrary">
</module>
</elements></p>
The elements element is required to be in the page. Inside this node you place the module nodes. Each module node does one type of similar action. Modules are used for placing files in the appropriate folders. In this feature we have a module called "ViewPhoto". This module places an aspx file in a directory on the Sharepoint site. The path is the location of the file or files in relation to the Elements.xml file. In this case the files are located in a folder called Pages. The URL attribute tells the feature where in the Sharepoint structure to put the files in this module. In this case it is the top level Pages list. The RootWebOnly attribute says if the files can only be accessed in the root web for the site.
Within the module node you place file nodes that specify the actual file. The URL attribute is the URL you want in the Sharepoint structure for this file. Typ determines if the file shows up in the page libraries. If you use GhostableInLibrary, the page will show up when you browse to the pages library.
Within the file node you can place property nodes that give additional attibutes for the file. In this case we have a title property and a description property. This allows for more descriptive information about the files.
Some things to look out for are the naming conventions in Sharepoint 2007. In some areas a library will be called PublishingImages but can be referenced using just Images. When creating features if you get some of the parts wrong, you can mess up the file system and the default templates for a Sharepoint site. Trust me on this one, I will explain some of the mistakes we have made and the issues we have found in later posts.
For now here are some more reference sites that explain more of the options for the Elements.xml file:
http://msdn2.microsoft.com/en-us/library/ms453137.aspx
http://msdn2.microsoft.com/en-us/library/ms434127.aspx
In the next few posts I will demonstrate how to do various activities using features.
Labels: Elements.xml, features, MOSS
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home