Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

On my main landing page of SharePoint, I'm using a few CQWPs and the Blank Web Parts Page layout. One will show your upcoming tasks, one will show the projects you're a member or lead of, etc. I have most of the CQWPs in the Center Left zone. Center and Center Right zones are always populated with something. If a CQWP in the Center Left zone returns no results, the Center and Center Right zone are pushed below the Center Left zone, instead of sitting to the right of Center Left. Anyone know how I can keep the Center and Center Right zones in place even if the CQWP returns no results?

share|improve this question
    
@RobertLindgren Actually it's an XSL issue. –  Daniel Ziga May 21 '13 at 13:47
    
@RobertLindgren It should, yes. But css alone cannot fix it when the very HTML structure becomes broken along the way. –  Daniel Ziga May 21 '13 at 13:50
    
True that! I have not seen exactly how it breaks the layout so there of my answer. Will clean my earlier comments. –  Robert Lindgren May 21 '13 at 13:52

1 Answer 1

up vote 5 down vote accepted

I'm guessing this is SP2013, as I myself have only encountered this in SP2013.

My personal explanation to this:

SharePoint 2013 Content By Query web part has a minor bug in its early releases. When returning no items it accidentally breaks the HTML structure of the page.

My solution:

Open the ContentQueryMain.xsl in SharePoint Designer. Find the XSL template OuterTemplate.Empty. As you can see it poorly handles the There exist no items situation.

Replace the template with this:

<xsl:template name="OuterTemplate.Empty">
  <xsl:param name="EditMode" />
  <xsl:choose>
    <xsl:when test="$EditMode = 'True' and string-length($cbq_errortext) = 0">
      <div class="wp-content description">
        <xsl:value-of disable-output-escaping="yes" select="$cbq_viewemptytext" />
      </div>
    </xsl:when>
    <xsl:otherwise>
      <div style="display:none">No content found</div>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

This way it renders something when there's nothing else to render and it does not break the HTML structure of the rest of the page.

I hope this solves your issue.

share|improve this answer
1  
Yep, SP2013. That solved the issue. Thank you good sir! –  Trenton Mak May 21 '13 at 14:02
    
thanks that was really helpful!!!! –  chana levy Jul 9 at 11:19
    
@chanalevy You're welcome :) –  Daniel Ziga Jul 9 at 13:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.