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

I'm trying to pull in custom columns from a SP list, and it works fine, but now I have to figure out how to do a for-each instead since it needs to pull in all items not just one.

Here's where I am so far:

<xsl:template name="forSale" match="Row[@Style='forSale']" mode="itemstyle">
    <div class="wrapper">
        <div id="banner-slide">
            <ul class="bjqs">
                <li><a href="{@FileURL}" />'><img src="{@ThumbnailURL}" title="{@Caption}" /></a></li>
            </ul>
        </div>
    </div>
</xsl:template>

The <li> part is the one I need to do a for-each on. Any ideas how to accomplish this?

EDIT: How about this instead?

SharePoint's ItemStyle template pulls in each row from a list automatically, so how would I pull this piece before the ItemStyle

<div class="wrapper">
        <div id="banner-slide">
            <ul class="bjqs">

And this piece of code after ItemStyle?

</ul>
        </div>
    </div>

This is how my ItemStyle would look then:

<xsl:template name="forSale" match="Row[@Style='forSale']" mode="itemstyle">
    <li><a href="{@FileURL}" />'><img src="{@ThumbnailURL}" title="{@Caption}" /></a></li>
</xsl:template>
share|improve this question

3 Answers 3

If your match is correct, do something of the following:

<xsl:for-each select="forSale">
  <li>
    <a href="<xsl:value-of select='FileURL' />">
       <img src="<xsl:value-of select='ThumbnailURL' />" 
            title="<xsl:value-of select='Caption' />" />
    </a>
  </li>
</xsl:for-each>

For more reference, take a look at MSDN <xsl:for-each> Element

share|improve this answer
    
What happens when I do this is that each item gets its own <div class="wrapper"> and it's own ul. In other words, that whole code is repeated, whereas I only need the <li> piece to repeat. –  zen Dec 12 '12 at 20:26
    
@zen Have you tried to place the foreach statement just including the <li></li> tags, since that's what you want to have repeated? –  Benny Skogberg MCSA Dec 12 '12 at 20:31
    
@zen I need to see the source of FileURL, ThumbnailURL and Caption to know what to select from in my for-each statement... –  Benny Skogberg MCSA Dec 12 '12 at 20:36
    
I added the XML output of that entire SharePoint list. Does that help? –  zen Dec 12 '12 at 21:27

See if this helps:

                  <xsl:for-each select="rows\row">
                    <li>
                      <a>
                        <xsl:attribute name="href">
                          <xsl:value-of select="{@FileURL}" />
                        </xsl:attribute>
                        <xsl:attribute name="src">
                          <xsl:value-of select="{@ThumbnailURL}" />
                        </xsl:attribute>
                        <xsl:attribute name="title">
                          <xsl:value-of select="{@Caption}" />
                        </xsl:attribute>
                      </a>
                    </li>
                  </xsl:for-each>

Please correct the "Rows\Row" as I'm not exactly sure about the list schema.

share|improve this answer
    
Nope that doesn't work either. I had to put src and title within img tag, but it still didn't work. I changed my original post to maybe make it easier. –  zen Dec 17 '12 at 15:54
up vote 3 down vote accepted

I was able to do it by modifying the ContentQueryMain.xsl file to insert non-repeating markup before and after content query as shown here.

http://blog.mastykarz.nl/wrapping-contents-content-query-web-part-additional-markup/

share|improve this answer

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.