Grounding.co.za

Technology information for IT specialists
Welcome to Grounding.co.za Sign in | Join | Help
in Search

Tech Talk with Brett Maytom

February 2008 - Posts

  • The content of a SharePoint ElementManifest file

    Using a feature or site definition, you are able to provision different content to a SharePoint site.  This post gives a high level overview of what elements can be provisioned through a feature.

    In my previous post Describing the ElementManifests section in a SharePoint feature.xml file I discussed the ElementManifest section within a feature.xml file.  The Element manifest will point to an elements file which contains a root Elements element and various types.  The basic file is shown below.

    <?xml version="1.0" encoding="utf-8" ?>
    <
    Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <
    ContentType />
    <
    ContentTypeBinding />
    <
    Control />
    <
    CustomAction />
    <
    CustomActionGroup />
    <
    DocumentConverter />
    <
    FeatureSiteTemplateAssociation />
    <
    Field />
    <
    HideCustomAction />
    <
    ListInstance />
    <
    ListTemplate />
    <
    Module />
    <
    Receivers />
    <
    UserMigrator />
    <
    Workflow />
    </
    Elements>

    The different content that can be provisioned is described below

    ContentType

    The ContentType element allows you to provision content types.  A content type allows you to define a reusable schema with its columns and forms.

     

    ContentTypeBinding

    The ContentTypeBinding element allows you to bind a content type to a list.

     

    Control

    The Control element allows you to define Delegate controls which you can include in your master, site, application and server side controls.  Different features can provision the same control, however with different sequence numbers.  The control with the lowest sequence number will actually be rendered.

     

    CustomAction

    Custom actions are used to create links in the SiteActions, Top Links, Quick Links and other menus.  These custom actions can also target links to other pages such as a "create" page or "application management" page.

     

    CustomActionGroup

    A CustomActionGroup element is used to group a set of CustomAction elements, i.e. CustomActions are nested child elements of a CustomActionGroup.  This helps with sequencing custom actions and managing their visibility as a group instead of individually

     

    DocumentConverter

    A DocumentConverter element allows you to provision a custom document converter that converts file of type A to a file of type B. 

     

    FeatureSiteTemplateAssociation

    The FeatureSiteTemplateAssociation allows you to link a feature to a site definition.  When you provision a site by choosing a configuration in a site definition, the linked features will also be provisioned.

     

    Field

    A field allows you to define a site column.  A site column allows you to define a reusable column for lists that can be reused across lists even in different sites.

     

    HideCustomAction

    The HideCustomAction allows you to hide existing actions that have been provisioned on the site. 

    ListInstance

    The ListInstance element specifies default data with which to provision the given list type. This element maps to the List element previously located within the

    ListTemplate

    The ListTemplate element is used to refer to list defined in a Schema.xml file.  You can then use the list template to create an instance of a list.

    Module

    A module element allows you to provision actual files to share point.  These files can be actual files that are ghosted or they can be unghosted files.  Site pages can also be provisioned with web parts placed into zones.

    Receivers

    Receivers allow you to provision event receivers that listen to events on lists.  You will also need to provision your own dll that has the code that will process the event.

    UserMigrator

    Currently undocumented and marked as "reserved for internal use".  (soz for not digging into this, but there is so much more I can blog on).

    Workflow

    The workflow element allows you to provision custom workflow that you have created.

    Tips

    • Rather create many element files as it is easier to manage than one large element file.

    See Also

    Posted Feb 23 2008, 10:44 AM by Brett with 1 comment(s)
    Filed under:
  • Describing the ElementManifests section in a SharePoint feature.xml file

    In a previous post Creating a simple SharePoint Feature.xml file I went through what is in a feature.xml file; however I did not go through the child collection elements such as the ElementsManifests.

    SharePoint content such as site columns, content types, lists, web parts, pages  and all other content are provisioned through SharePoint the ElementsManifests when the feature is activated. 

    Types of ElementsManifests

    When looking at the ElementsManifests element in the xml file, you are able to provision many different ElementManifest or an ElementFile.

    ElementManifest

    The ElementManifest element is to point the feature to another xml file that contains CAML that defines various content including:

    • Content Type
    • Content Type Binding
    • Control
    • Custom Action
    • Custom Action Group
    • Document Converter
    • Features Site Template Association
    • Field
    • Hide Custom Action
    • List Instance
    • List Template
    • Module
    • Receivers
    • User Migrator
    • Workflow
      ElementFile When your feature has deployed other content such as web pages, controls, master pages, css files and the feature is dependant on these files, you need to add an ElementFile.  SharePoint does not actively provision the file, however it keeps a reference to the file and links its usage to the feature.

    Example

    The following code sample shows a sample ElementManifests element in a feature.xml

    <ElementManifests>
      <!-- These manifests define different content to be provisioned for the site collection -->
      <ElementManifest Location="SiteColums\elements.xml" />
      <ElementManifest Location="ContentTypes\elements.xml" />
      <ElementManifest Location="Workflows\elements.xml" />
      <ElementManifest Location="ListTemplates\elements.xml" />
      <ElementManifest Location="ListInstances\elements.xml" />
      <ElementManifest Location="LibraryInstances\elements.xml" />
      <ElementManifest Location="Workflows\elements.xml" />
      <!-- The following allows SharePoint to track usage of these files -->
      <ElementFile Location="MasterPages\groudning.brand.master"/>
      <ElementFile Location="MasterPages\groudning.site.master"/>
      <ElementFile Location="Styles\Groudning\groudning.css"/>
      <ElementFile Location="Styles\Groudning\logo.png"/>
      <ElementFile Location=""/>
    </ElementManifests>

    Tips

    • Rather create many ElementManifest files instead of one large file as this will give you greater control over making changes, finding content.
    • Point each ElementManifest location to its own sub directory as this will help you manage your projects files a bit easier instead of having lists of files.
    • Add ElementFile elements to other resources that your feature uses as to allow SharePoint to manage usage of these resources.

    See Also

    Posted Feb 23 2008, 08:52 AM by Brett with no comments
    Filed under:
  • Creating a simple SharePoint Feature.xml file

    The Feature.xml follows the Collaborative Application Markup Language (CAML) convention to define a feature.

    <?xml version="1.0" encoding="utf-8" ?>
    <Feature 
          xmlns="http://schemas.microsoft.com/sharepoint/"
          Id="11111111-1111-1111-1111-111111111111"
          Title=""
          Scope="Web"
          >
      <!-- Element Manifests -->
      <ElementManifests>
        <ElementManifest />
        <ElementFile />
      </ElementManifests>
      
      <!-- Dependencies -->
      <ActivationDependencies>
        <ActivationDependency />
      </ActivationDependencies>
      
      <!-- Properties -->
      <Properties>
        <Property />
      </Properties>
    </Feature>

    Feature attributes

    You will need to create yourself a Feature.xml file using any text \ xml editor.  The xml file should contain a Feature element with two required attributes, Id and Scope and a useful title attribute.

    xmlns (recommended)The namespace that the feature element belongs to and should be http://schemas.microsoft.com/sharepoint.  In visual studio, this will assist with Intellisense and syntax errors.Id (Required)The Id is a globally unique identifier (GUID) for the feature.  Each feature you create should have a unique ID.  To create a GUID from Visual Studio, Choose the Tools \ Create GUID menu.Scope (Required)The scope defines where the feature can be activated and can be one of the following Farm, WebApplication, Site (Site collection) and Web (Web Site). Title (recommended)The title is optional text (max 255 chars) that will be displayed in the list of available features.  Give short names that describe your featureDescription (optional)Write a detailed description of what your feature does, this will be displayed in the UI where the feature is activated. ImageUrl This attribute defines a relative Url to an image file that represents the feature.  The feature should be placed into the sites images folder, typically it is 12\TEMPLATE\IMAGES.  I would suggest creating a sub folder under images for your own images.ImageUrlAltText (Optional)Contains alternate text for the image of the feature. Hidden (Optional)The hidden attribute can be set to either TRUE or FALSE (default).  If the attribute is set to true, the feature will not appear in the UI and can only be activated from the command line using STSADM -o activatefeatureVersion (Optional)Specifies a System.Version compliment version number of the feature, i.e. Major.Minor.Revision.Build.  The version number can be up to foru numbers separated by decimals.  An example would be 1.0.0.0Creator (Optional)Any text to define the author or application that created the feature.

    ReceiverAssembly (Optional with ReceiverClass) This attribute is used to indicate the assembly and class to automatically execute when the feature is either installed, uninstalled, activated or deactivated.  This attribute must be used with the ReceiverClass.  The assembly name should be a four-part strong name for the assembly, i.e.  Dll name, Version, Culture, PublicKeyToken.

    ReceiverClass (Optional with ReceiverAssembly) This attribute defines the class name including the namespace of the .NET class in the ReceiverAssembly that implements the Feature events.  This attribute must be set with the ReceiverAssembly.  When the feature is installed, uninstalled, activated or deactivated the provisioning engine will load the ReceiverAssembly and create an instance of the ReceeiverClass.  The provisioning engine will then execute the relevant overridden method,

    Additional attributes also exist, including

    • ActivateOnDefault
    • AlwaysForceInstall
    • AutoActivateInCentralAdmin
    • DefaultResourceFile
    • RequireResources
    • SolutionId

    Feature Child Elements

    ActivationDependencies

    The ActivationDependencies child element defines a list of other features that the current feature depends on. 

    ElementManifests

    The ElementManifests element is used to define various feature elements and functionality. 

    Properties

    The Properties element defines default values for any feature property.

    Feature Deployment Location

    Features are deployed to the [12 Hive]\TEMPLATE\FEATURES folder.  In other posts there will be discussions on how to package and deploy features properly.

    image

    Posted Feb 02 2008, 10:26 AM by Brett with 1 comment(s)
    Filed under:
More Posts
Add to Technorati Favorites
Powered by Community Server (Commercial Edition), by Telligent Systems
Afrigator