Tuesday, October 25, 2011

Content By Query WebPart outputs incorrect url when there is no root sitecollection

If you have a webapplication with no sitecollection at the root url (e.g. all site collection are located under http://<webapp>/sites/…) and you use the CBQWP to query for list items (events / tasks./ … anything but documents), you will receive a ‘404 page not found’ when clicking the link.

The CBQWP uses the CopyUtil.aspx page to redirect you to the item in question (see http://weblogs.asp.net/jan/archive/2008/02/26/copyutil-aspx-a-little-sharepoint-gem.aspx). If there is no sitecollection at the root url, the site collection url will be missing from the url that is generated.

To solve this issue, edit the ‘ContentQueryMain.xslt’ file and change

<xsl:if test="$UseCopyUtil = 'True'">
<xsl:value-of select="concat('/_layouts/CopyUtil.aspx?Use=id&Action=dispform&ItemId=',@ID,'&ListId=',@ListId,'&WebId=',@WebId,'&SiteId=',$SiteId)"/>
</xsl:if>

into

<xsl:if test="$UseCopyUtil = 'True'">
<xsl:value-of select="concat($SiteUrl,'/_layouts/CopyUtil.aspx?Use=id&Action=dispform&ItemId=',@ID,'&ListId=',@ListId,'&WebId=',@WebId,'&SiteId=',$SiteId)"/>
</xsl:if>

No comments:

Post a Comment