May 14, 2013

Content Query Web Part Breaks Page Layout in SP2013

Content Search Web Part replaces Content Query Web Parts in SharePoint 2013 on many occasions. This probably is the reason why it has taken this long for me to discover this rather annoying SharePoint bug: Content Query Web Part breaks a page layout built with div-elements, because the default web part (or the XSLTs?) seems to miss a </div> closing tag!

Everything is ok in edit mode, for what ever additional wrapper reasons:

but when I click my way out of edit mode, the page breaks:

In FireBug, I added a </div> tag to the page's source code (which is perfectly ok when no CQWP is added to the page) and this fixes the problem:

In real life, this obviously won't do. So as a workaround, I added a table element to the Page Layout code, inside the div-elements as a wrapper for the web part zones: 

<div id="rightcolumn">
  <table width="100%"><tr><td>
    <div class="ms-webpart-zone ms-fullWidth">

Not an especially pretty insert, but the easiest fix I came up with for now.


Anonymous said...

Another fixed we found was to implement tags around each web part zone div.

Thought this is a new HTML5 tag so it may only be supported in newer browsers. If you are trying to suport anything older it may pay run with the table fix as stated above.


Anonymous said...

Well it edited out the tags in my last post but it was meant to be section tags

Marcelo said...

In My case, I noticed that the problem was a -tr- without a td on ItemStyle. Seems to be the normal behavior, SharePoint provide us a row -tr- and let us implement how many -td- we want.

So on ItemStyle, right after the template declaration, I put a -td- content -/td-

-!-- My Custom ItemStyle ---
-xsl:template name="MyItemStyle"-
-td- -!-- here ---
-xsl:value-of select="@Content" disable-output-escaping="yes"/xsl:value-of

It solved my problem perfectly.

ps: it was working well on SharePoint 2010. The layout problem came after migrate to SP 2013.

I removed all the tags because is not permmited on this comment.

Wine Recipes said...

Good readiing your post