We are using a content query webpart on a page to show some related documents. It needs to be updated immediately when the page is updated so the 15 minute search web part delay is not an option for us. We want to use the CQWP.

We also want to make a few changes to how the items are displayed. I've tracked down the ItemStyle.xsl and figured out how to make a few changes. I based our change on the WithDocIcon template already in the file. We wanted to use the large icons and this is what I could come up with.

<xsl:template name="CustomIconWithDoc" match="Row[@Style='KPDoc']" mode="itemstyle">

    <xsl:variable name="SafeLinkUrl">
        <xsl:call-template name="OuterTemplate.GetSafeLink">
            <xsl:with-param name="UrlColumnName" select="'LinkUrl'" />

    <xsl:variable name="DisplayTitle">
        <xsl:call-template name="OuterTemplate.GetTitle">
            <xsl:with-param name="Title" select="''" />
            <xsl:with-param name="UrlColumnName" select="'LinkUrl'" />
            <xsl:with-param name="UseFileName" select="0" />

    <div class="item">
        <xsl:if test="string-length(@DocumentIconImageUrl) != 0">
            <xsl:variable name="largeicon" select="substring-after(@DocumentIconImageUrl,'IMAGES/')" />
            <div class="pull-left">
                <img src="/_layouts/15/IMAGES/lg_{$largeicon}" title="" />
        <div class="link-item bfc">
            <a href="{$SafeLinkUrl}">
                <xsl:value-of select="$DisplayTitle" />
            <div class="description">
                <xsl:value-of select="@Description" />


So far that took a lot of research and it seems to be working fine. We need to do a little conditional formatting now and I can't figure out how to do it.

Some of the items returned by the CQWP are from a based on the Link to a document content type in a document library. We have two problems with how these are displayed.

First issue

The link is showing the name of the item, for example, Link to useful site.aspx. We don't want to include the extension for these links, but we do want the extension for the other documents in the list.

I think I could use substring-before($DisplayTitle,'.aspx') but I'm not sure how to only do that if the Content type is "Link to document," but I can't figure out how to test for that. I've tried things like <xsl.if test="ContentType = 'Link to document'" /> (Also tried @ContentType and $ContentType, but the content type doesn't seem to be in the data source.)

Second issue

The links for the item as something like <site>/Documents/name-of-link.aspx and then when the user clicks the link they go to that url and get immediately redirected to the actual location. We want to just have the final destination link on the page.

The value I want is stored in the property URLOWSURLH but that value doesn't seem to be available.

How can I see what values are available to me? I tried to use <xsl.value-of select="current()" /> to see the current node, but I don't get anything I can see.

BTW I've followed or tried to follow the following tutorials and resources

Does anybody have skills in this arena? Can anybody help?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.