locked
<div> tag problem inside xsl code in content query webpart RRS feed

  • Question

  • Hi,

    I am customizing the itemstyle xsl file in content query webpart. I added <div> tag inside the xsl file. But it repeats no. of times while retrieving the list item and displaying in content query webpart.

    e.g.

    I display 3 list items in div . for that I wrote the code like,

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

    <div id="test">

    item1...

    item2...

    item3...

    </div>

    </xsl:template>

    But div is displayed in content query webpart 3 times as below.

    item1...

    item2...

    item3...

    item1...

    item2...

    item3...

    item1...

    item2...

    item3...

    Please help...


    Knowledge is power.

    Wednesday, March 14, 2012 5:57 AM

Answers

  • You are placing the div in side item template which is called for each item once. For example: if your querry return 3 records, for each record it will render your DIV once that means totally 3 times. You have to define how an item should look like in the template(XSLT file). This will be applied for all items your Content Query Webpart returns.

    Check this link http://msdn.microsoft.com/en-us/library/ie/bb447557.aspx, It will help you to understand which xslt file is used for what purpose. If some thing should appear only once in Content Query webpart you have to specify it either in ContentQueryMain.xsl or Header.xsl based on location it shoudl appear.
    Wednesday, March 14, 2012 2:13 PM