I have a list of links which has a lookup column for category which is another list, so my lists are:

Action Category - Title Actions - Title, Category, Link

I want to display the links in a 3 column grid and am using bootstrap/foundation, so after every 3rd column I need to close the row div and open another one.

Can I achieve this using something like the CQWP or am I better off developing a user control?

1 Answer 1


You could use a DVWP. This is code I've used numerous times to show multiple column layouts with DVWPs.

        <xsl:template name="dvt_1.body">
            <xsl:param name="Rows"/>
<!-- start the first row of the table outside of the row loop -->
                    <xsl:for-each select="$Rows">
                        <xsl:call-template name="dvt_1.rowview" />
<!-- end the last row of the table -->

<xsl:template name="dvt_1.rowview">
            <td class="ms-vb" style="width:120px; padding-left: 20px;">
                <xsl:value-of select="@Title" />
<!-- after each 4th item, insert a closing tr tag and an opening tr tag for the next row -->
            <xsl:if test="position() mod 4 = 0">
                <xsl:text disable-output-escaping="yes">&lt;/tr&gt;</xsl:text>
                <xsl:text disable-output-escaping="yes">&lt;tr&gt;</xsl:text>

CQWP uses XSLT as well, but the code is in several different files. If you want to customize a CQWP you should create copies instead of editing the originals. Data rows are defined in the ItemStyle.xls and the templates for the outer loops are in ContentQueryMain.xsl. The XSLT for CQWP is not as straightforward as the DVWP and it will take a while to figure out where you need to add your customisations.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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