Custom Branded Links Section – Using DVWP XSL
How about having a quick link section with images and links in our SharePoint site? yeah, good idea. How about make it configurable? I mean, quick link titles, links, images manageable by end user.
Well, at high level idea, what you have to do is:
1. Create a list with Title, Description, image, etc columns.
2. Customize the SharePoint data view web part; once done export and import the web part where ever we need.
Sounds good? yeah, we’ll look in to the implementation
Create a simple list with Title, Description, and image columns: Here is one I’ve done:
and i’ve filled the list with few entries, so now my list is looking like:
So, our list is ready, we’ve to customize our list by using the Data view web part. Or you can just copy-paste the below code, which I took from my customized data view web part, into a text file, name it to xxxx.webpart, and import this web part to your page 🙂
<webPart xmlns=”https://schemas.microsoft.com/WebPart/v3″>
<metaData>
<type name=”Microsoft.SharePoint.WebPartPages.DataFormWebPart,
Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” />
<importErrorMessage>Cannot import this Web Part.</importErrorMessage>
</metaData>
<data>
<properties>
<property name=”MissingAssembly” type=”string”>Cannot import this Web Part.</property>
<property name=”FireInitialRow” type=”bool”>True</property>
<property name=”TitleIconImageUrl” type=”string” />
<property name=”HelpMode” type=”helpmode”>Modeless</property>
<property name=”CacheXslStorage” type=”bool”>True</property>
<property name=”ViewContentTypeId” type=”string” />
<property name=”Description” type=”string” />
<property name=”DataSourcesString” type=”string”><%@ Register TagPrefix=”sharepoint” Namespace=”Microsoft.SharePoint.WebControls” Assembly=”Microsoft.SharePoint,
Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” %><%@
Register TagPrefix=”webpartpages” Namespace=”Microsoft.SharePoint.WebPartPages”
Assembly=”Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral,
PublicKeyToken=71e9bce111e9429c” %><sharepoint:SPDataSource runat=”server”
DataSourceMode=”List” SelectCommand=”&lt;View&gt;&lt;/View&gt;”
UpdateCommand=”” InsertCommand=”” DeleteCommand=”” UseInternalName=”True”
ID=”dataformwebpart2″><SelectParameters>
<webpartpages:DataFormParameter ParameterKey=”ListID” PropertyName=”ParameterValues”
DefaultValue=”{E01A58C6-C760-4C5B-A3EB-7CD61F94281B}” Name=”ListID”></webpartpages:DataFormParameter>
</SelectParameters>
<UpdateParameters>
<webpartpages:DataFormParameter ParameterKey=”ListID” PropertyName=”ParameterValues”
DefaultValue=”{E01A58C6-C760-4C5B-A3EB-7CD61F94281B}” Name=”ListID”></webpartpages:DataFormParameter>
</UpdateParameters>
<InsertParameters>
<webpartpages:DataFormParameter ParameterKey=”ListID” PropertyName=”ParameterValues”
DefaultValue=”{E01A58C6-C760-4C5B-A3EB-7CD61F94281B}” Name=”ListID”></webpartpages:DataFormParameter>
</InsertParameters>
<DeleteParameters>
<webpartpages:DataFormParameter ParameterKey=”ListID” PropertyName=”ParameterValues”
DefaultValue=“{E01A58C6-C760-4C5B-A3EB-7CD61F94281B}” Name=”ListID”></webpartpages:DataFormParameter>
</DeleteParameters>
</sharepoint:SPDataSource>
</property>
<property name=”AllowZoneChange” type=”bool”>True</property>
<property name=”ParameterBindings” type=”string”>
<ParameterBinding Name=”ListID” Location=”None” DefaultValue=”{E01A58C6-C760-4C5B-A3EB-7CD61F94281B}“/>
<ParameterBinding Name=”dvt_apos” Location=”Postback;Connection”/>
<ParameterBinding Name=”UserID” Location=”CAMLVariable” DefaultValue=”CurrentUserName”/>
<ParameterBinding Name=”Today” Location=”CAMLVariable” DefaultValue=”CurrentDate”/>
</property>
<property name=”PageSize” type=”int”>-1</property>
<property name=”TitleUrl” type=”string” />
<property name=”ViewFlag” type=”string”>0</property>
<property name=”Xsl” type=”string”><xsl:stylesheet xmlns:x=”https://www.w3.org/2001/XMLSchema”
xmlns:d=”https://schemas.microsoft.com/sharepoint/dsp” version=”1.0″
exclude-result-prefixes=”xsl msxsl ddwrt” xmlns:ddwrt=”https://schemas.microsoft.com/WebParts/v2/DataView/runtime”
xmlns:asp=”https://schemas.microsoft.com/ASPNET/20″ xmlns:__designer=”https://schemas.microsoft.com/WebParts/v2/DataView/designer”
xmlns:xsl=”https://www.w3.org/1999/XSL/Transform” xmlns:msxsl=”urn:schemas-microsoft-com:xslt”
xmlns:SharePoint=”Microsoft.SharePoint.WebControls” xmlns:ddwrt2=”urn:frontpage:internal”>
<xsl:output method=”html” indent=”no”/>
<xsl:decimal-format NaN=””/>
<xsl:param name=”dvt_apos”>’</xsl:param>
<xsl:variable name=”dvt_1_automode”>0</xsl:variable>
<xsl:template match=”/”>
<xsl:call-template name=”dvt_1″/>
</xsl:template>
<xsl:template name=”dvt_1″>
<xsl:variable name=”dvt_StyleName”>Table</xsl:variable>
<xsl:variable name=”Rows” select=”/dsQueryResponse/Rows/Row”/>
<table border=”0″ width=”100%” cellpadding=”2″ cellspacing=”0″
class=”style1″>
<tr valign=”top”>
<xsl:if test=”$dvt_1_automode = ‘1’” ddwrt:cf_ignore=”1″>
<th class=”ms-vh” width=”1%” nowrap=”nowrap”></th>
</xsl:if>
</tr>
<xsl:call-template name=”dvt_1.body”>
<xsl:with-param name=”Rows” select=”$Rows”/>
</xsl:call-template>
</table>
</xsl:template>
<xsl:template name=”dvt_1.body”>
<xsl:param name=”Rows”/>
<xsl:for-each select=”$Rows”>
<xsl:call-template name=”dvt_1.rowview”/>
</xsl:for-each>
</xsl:template>
<xsl:template name=”dvt_1.rowview”>
<tr>
<xsl:if test=”position() mod 2 = 1″>
<xsl:attribute name=”class”>ms-alternating</xsl:attribute>
</xsl:if>
<xsl:if test=”$dvt_1_automode = ‘1’” ddwrt:cf_ignore=”1″>
<td class=”ms-vb” width=”1%” nowrap=”nowrap”>
<span ddwrt:amkeyfield=”ID” ddwrt:amkeyvalue=”ddwrt:EscapeDelims(string(@ID))”
ddwrt:ammode=”view”></span>
</td>
</xsl:if>
<td style=”width: 10px”><span style=”text-decoration: none;”>
<a href=”Lists/Quick Links/DispForm.aspx?id={@ID}”><img border=”0″ src=”{substring-before(@Image,
‘, ‘)}” alt=”{substring-after(@Image, ‘, ‘)}”/></a></span>
</td>
<td style=”width: 3px”></td>
<td class=”ms-vb” valign=”top” >
<a href=”Lists/Quick Links/DispForm.aspx?id={@ID}”><xsl:value-of
select=”@Title” /></a><BR/>
<xsl:value-of select=”@Description”/>
</td>
</tr>
</xsl:template></xsl:stylesheet></property>
<property name=”NoDefaultStyle” type=”string”>TRUE</property>
<property name=”Direction” type=”direction”>NotSet</property>
<property name=”UseSQLDataSourcePaging” type=”bool”>True</property>
<property name=”ListName” type=”string” null=”true” />
<property name=”Hidden” type=”bool”>False</property>
<property name=”DisplayName” type=”string” />
<property name=”SampleData” type=”string” null=”true” />
<property name=”HelpUrl” type=”string” />
<property name=”ChromeType” type=”chrometype”>Default</property>
<property name=”CatalogIconImageUrl” type=”string” />
<property name=”Height” type=”string” />
<property name=”DataFields” type=”string”>@Title,Title;@Description,Description;@Image,Image;@ID,ID;@ContentType,Content
Type;@Modified,Modified;@Created,Created;@Author,Created By;@Editor,Modified
By;@_UIVersionString,Version;@Attachments,Attachments;@File_x0020_Type,File
Type;@FileLeafRef,Name (for use in forms);@FileDirRef,Path;@FSObjType,Item
Type;@_HasCopyDestinations,Has Copy Destinations;@_CopySource,Copy
Source;@ContentTypeId,Content Type ID;@_ModerationStatus,Approval
Status;@_UIVersion,UI Version;@Created_x0020_Date,Created;@FileRef,URL
Path;</property>
<property name=”Default” type=”string” />
<property name=”ChromeState” type=”chromestate”>Normal</property>
<property name=”DataSourceID” type=”string” />
<property name=”AllowClose” type=”bool”>True</property>
<property name=”CacheXslTimeOut” type=”int”>86400</property>
<property name=”AllowMinimize” type=”bool”>True</property>
<property name=”AllowEdit” type=”bool”>True</property>
<property name=”XslLink” type=”string” null=”true” />
<property name=”Title” type=”string”>Quick Links</property>
<property name=”Width” type=”string” />
<property name=”ShowWithSampleData” type=”bool”>False</property>
<property name=”ExportMode” type=”exportmode”>All</property>
<property name=”AllowHide” type=”bool”>True</property>
<property name=”AllowConnect” type=”bool”>True</property>
</properties>
</data>
</webPart>
</webParts>
Important: You have to change your list ID and list name as in the code higlighed
Similar way, just by re-arranging the <TD>’s you can design the quick links sections as in the below image.
will it work with 2013?
superb…