Get Current Page URL using XSL for Content Query Web Part
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
- 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,’&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. http://msdn.microsoft.com/en-us/library/aa505323.aspx (it is 2003 version article but most of the functions work ) and more http://weblogs.asp.net/soever/archive/2005/01/03/345535.aspx