Press ESC to close

SharePoint – Content Query Web Part open item in detail view

I wrote an article about opening an item with the CQWP in the edit form. I also found out how to open an item with the detail view. Just follow these instructions:

  • Open SharePoint Designer
  • Click at All Files
  • Click at Style Library
  • Click at XSL Style Sheets
  • Make a back-up of ContentQueryMain and ItemStyle
  • Check out ContentQueryMain and add the following code:

<xsl:template name=”OuterTemplate.GetDisplayLink”>
<xsl:param name=”UrlColumnName”/>
<xsl:if test=”$UseCopyUtil = ‘True'”>
<xsl:value-of select=”concat($RootSiteRef,’/_layouts/CopyUtil.aspx?Use=id&amp;Action=dispform&amp;ItemId=’,@ID,’&amp;ListId=’,@ListId,’&amp;WebId=’,@WebId,’&amp;SiteId=’,$SiteId,’&amp;Source=’,$Source)”/>
</xsl:if>
<xsl:if test=”$UseCopyUtil != ‘True'”>
<xsl:call-template name=”OuterTemplate.GetSafeStaticUrl”>
<xsl:with-param name=”UrlColumnName” select=”$UrlColumnName”/>
</xsl:call-template>
</xsl:if>
</xsl:template>

  • Save and check in and publish
  • Check out ItemStyle and add the following code:

<xsl:template name=”NameOfTheTemplate” match=”Row[@Style=’ NameOfTheTemplate’]” mode=”itemstyle”>
<xsl:variable name=”SafeLinkUrl”>
<xsl:call-template name=”OuterTemplate.GetDisplayLink”>
<xsl:with-param name=”UrlColumnName” select=”‘LinkUrl'”/>
</xsl:call-template>
</xsl:variable>
<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:call-template>
</xsl:variable>
<div>
<xsl:call-template name=”OuterTemplate.CallPresenceStatusIconTemplate”/>
<a onclick=”javascript:SP.UI.ModalDialog.ShowPopupDialog(‘{$SafeLinkUrl}’); return false;” onmouseover=”javascript:this.style.cursor=’hand’;” title=”{@LinkToolTip}”>
<xsl:value-of select=”$DisplayTitle”/>
</a>
</div>
</xsl:template>

  • Save, Check in and Publish.

The last thing you have to do is edit the CQWP and use the itemstyle. That should do the trick!

Jasper Oosterveld

My name is Jasper Oosterveld. I am a Microsoft MVP, Data Security & Microsoft 365 Consultant based in the Netherlands. I’ve spent the last decade helping organizations tackle complex challenges around Governance, Adoption and Data Security with Microsoft Purview. My mission? To empower companies to protect their data and streamline collaboration in Microsoft 365, all while keeping governance and adoption at the forefront.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.