Microsoft 365 SharePoint

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!

You Might Also Like

No Comments

Leave a Reply

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