Wednesday, June 22, 2011

Provisioning URL values with description using element manifest

When provisioning files/items that contain an URL typed field you probably want to provide an url and description. When using an element manifest to provision some content you probably use something like this:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="Banners" Url="Banners">
<File Path="Banners\banner1.png" Url="banner1.png" Type="GhostableInLibrary">
<Property Name="URL" Type="string" Value="http://www.yellowred.nl"/>
<Property Name="NewWindow" Value="true"/>
</File>
</Module>
</Elements>
There’s no room for providing a description. The property element has the following ‘Type’ attribute options: int, string, datetime. So no url type.

As you know the URL value is just a string with in specific format: <url>, <description>
You can also find this format when using SharePoint Manager 2010. Open the item containing the url field. Check the schema.xml and search for the url.

To provide a description to the url, provision your data like this:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="Banners" Url="Banners">
<File Path="Banners\banner1.png" Url="banner1.png" Type="GhostableInLibrary">
<Property Name="URL" Type="string" Value="http://www.yellowred.nl, Yellow and Red"/>
<Property Name="NewWindow" Value="true"/>
</File>
</Module>
</Elements>

1 comment:

Note: Only a member of this blog may post a comment.