Note that there are some explanatory texts on larger screens.

plurals
  1. POXSL counter on specific condition for SharePoint 2010 CQWP
    text
    copied!<p>This is the first time I have ever posted a question so apologese in advance if I jibber here.</p> <p>I am trying to put together a CQWP with jQuery tabs slider functionality. The HTML I want to output should be in the form of 2 UL's. The first with li anchor tags with #associated-ul-id </p> <p>The second ul's should have ids that associate with the list items in the first. Eg</p> <pre><code>&lt;div id="tabs" class="news"&gt; &lt;div class="news-pagination"&gt; &lt;a href="#" id="carouseltext-prev"&gt;&amp;laquo; Prev&lt;/a&gt; &lt;ul id="carouseltext" class="horizontal-text order"&gt; &lt;li&gt;&lt;a href="#tabs-1"&gt;System&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#tabs-2"&gt;School&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;a href="#" id="carouseltext-next"&gt;&amp;raquo; Next&lt;/a&gt; &lt;div class="clear"&gt;&amp;nbsp;&lt;/div&gt; &lt;/div&gt; &lt;ul id="tabs-1" class="feed order"&gt; &lt;li&gt;title 1&lt;/li&gt; &lt;li&gt;title 2&lt;/li&gt; &lt;/ul&gt; &lt;ul id="tabs-2" class="feed order"&gt; &lt;li&gt;title 3&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>The original XML starts off in the form </p> <p> </p> <p>My XSL goes through the XML twice to fill the 2 ul's. The first time it just adds a new list item when the __begincolumn and __begingroup variables are true. I striped down the functionality here to just output the header. Here's a stripped down version of the XSL</p> <pre><code> &lt;xsl:template match="/"&gt; &lt;xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row" /&gt; &lt;xsl:variable name="RowCount" select="count($Rows)" /&gt; &lt;xsl:variable name="FirstRow" select="1" /&gt; &lt;xsl:param name="ColNumber" select="1" /&gt; &lt;xsl:for-each select="$Rows" &gt; &lt;xsl:variable name="CurPosition" select="position()" /&gt; &lt;xsl:variable name="BeginNewsItemsList1" select="string('&amp;lt;ul id=&amp;quot;tabs-')" /&gt; &lt;xsl:variable name="BeginNewsItemsList2" select="string('&amp;quot;class=&amp;quot;feed order&amp;quot;&amp;gt;')" /&gt; &lt;xsl:variable name="BeginNewsItemsList" select="concat($BeginNewsItemsList1, $ColNumber, $BeginNewsItemsList2)" /&gt; &lt;xsl:if test="($CurPosition &amp;gt;= $FirstRow and $CurPosition &amp;lt;= $LastRow)"&gt; &lt;xsl:variable name="StartNewGroup" select="@__begingroup = 'True'" /&gt; &lt;xsl:variable name="StartNewColumn" select="@__begincolumn = 'True'" /&gt; &lt;xsl:when test="$StartNewGroup and $StartNewColumn"&gt; &lt;xsl:choose&gt; &lt;xsl:when test="$CurPosition = $FirstRow"&gt; &lt;xsl:value-of disable-output-escaping="yes" select="$BeginNewsItemsList" /&gt; &lt;/xsl:when&gt; &lt;xsl:otherwise&gt; &lt;!-- other instructions --&gt; &lt;/xsl:otherwise&gt; &lt;/xsl:choose&gt; &lt;/xsl:when&gt; &lt;xsl:when test="$StartNewGroup"&gt; &lt;xsl:call-template name="OuterTemplate.CallFooterTemplate"/&gt; &lt;xsl:value-of disable-output-escaping="yes" select="concat($EndColumn, $BeginNewsItemsList)" /&gt; &lt;/xsl:when&gt; &lt;xsl:otherwise&gt; &lt;/xsl:otherwise&gt; &lt;/xsl:if&gt; &lt;/xsl:for-each&gt; &lt;/xsl:template&gt; &lt;xsl:template name="OuterTemplate.Count"&gt; &lt;xsl:param name="ColNumber" /&gt; &lt;xsl:value-of select="$ColNumber + 1" /&gt; &lt;/xsl:template&gt; </code></pre> <p>For the second for-each loop I'm having trouble setting up a counter so that I can add the number to the end of the id for each new list id="tabs-1", id="tabs-2", etc.</p> <p>In theory I think I should set a parameter outside my for-each loop and then in the loop call a template that gets the parameter value and increments it. That would mean it would increment only when the template is called.</p> <p>I can't use position() for this as it doesn't correspond to the values I want. I've tried to follow a couple a few blogs about recursive programming with xsl, but I can't seem to find anything that works. I'm sure I'm just writing the XSL wrong, but I'm having a bit of a brain dump now.</p> <p>If anybody could point me in the right direction that would be awesome. Thanks very much.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload