Posts Tagged ‘XSL’

CQWP (Content Query Web Part) Display all fields + values

October 30, 2009 2 comments

Moved from old blogging site

Below is the code which I use frequently for my XSL development in CQWP. This xsl code gets all the data and values, this helps you identify all the data before you move on with visual html development. Initially I used this custom xslt to display all the field names in Content Query Web part. I modified it to see values along with field name. Its simple needs no explanation.

<xsl:template name="AllFields" match="Row[@Style='AllFields']" mode="itemstyle">
 <xsl:param name="CurPos"/>
 <xsl:variable name="SafeLinkUrl">
 <xsl:call-template name="OuterTemplate.GetSafeLink">
 <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
 <xsl:variable name="SafeImageUrl">
 <xsl:call-template name="OuterTemplate.GetSafeStaticUrl">
 <xsl:with-param name="UrlColumnName" select="'ImageUrl'"/>
 <xsl:variable name="DisplayTitle">
 <xsl:call-template name="OuterTemplate.GetTitle">
 <xsl:with-param name="Title" select="@Title"/>
 <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
 <xsl:variable name="LinkTarget">
 <xsl:if test="@OpenInNewWindow = 'True'" >_blank</xsl:if>
 <div id="linkitem" class="item">
 <xsl:for-each select="@*">
 <span style ="font:bold">    <xsl:value-of select="name()" /> </span>  : <xsl:value-of select="."/> <br/>



Categories: Content Query, Field, SharePoint, XSL, XSL Tags: ,

Get Current Page URL using XSL for Content Query Web Part

March 16, 2009 8 comments

I frequently write custom XSL templates for Content Query Web Part (CQWP) for Rolling up List Items. I use  CopyUtil.aspx for link items to to Display Form Pages which on close or after editing the items takes you back to default list item page instead of where CQWP is located.

You can either fix this by

  1. opening a item new window (target =”_blank”  in your href’s )

<a href=”{$DetailPageLink}” title=”{@LinkToolTip}” target=”_blank”>

2. Using Source attribute in your URL. SharePoint ListForm Pages use this to navigate back to location you arrived .

<xsl:variable name=”DetailPageLink” select=”concat($SafeLinkUrl,’&amp;Source=/myPage/CQWP.aspx’)” />
<a href=”{$DetailPageLink}” title=”{@LinkToolTip}”>

3. The Problem with above approach is, If I am reusing this template at different location(page or Site) I would need to recreate this template to just change the source attribute. Also in case you are moving XSL files between environments it could break.

To fix it you can probably use JavaScript to get your current Page URL. I won’t go over this. I will be using often ignored ddwrt xml namespace. (it is 2003 version article but most of the functions work ) and more

Read more…