Answer the question
In order to leave comments, you need to log in
How to organize pairwise output of list items in UMI.CMS?
Good afternoon!
It is required to implement the output of a list of elements in pairs, for example:
<div>
<span class="element-1">Элемент 1</span>
<span class="element-2">Элемент 2</span>
</div>
<div>
<span class="element-3">Элемент 3</span>
<span class="element-4">Элемент 4</span>
</div>
<xsl:template match="item" mode="portfolio_item">
<xsl:if test="position() mod 2 = 1">
<div>
</xsl:if>
<span class="element-{position()}" >
<xsl:value-of select='document(concat("upage://", @id,
".preview"))/udata/property/value' disable-output-escaping="yes" />
</span>
<xsl:if test="position() mod 2 = 0 or position() = last()">
</div>
</xsl:if>
</xsl:template>
Answer the question
In order to leave comments, you need to log in
Try like this:
<xsl:param name="colnum" select="2"/>
<xsl:template match="udata[@module = 'catalog'][@method = 'getObjectsList']">
<xsl:apply-templates select="lines/item[position() = 1]|lines/item[position() mod $colnum = 1]"/>
</xsl:template>
<xsl:template match="item">
<div>
<xsl:apply-templates select=".|following-sibling::item[position() < $colnum]" mode="div"/>
</div>
</xsl:template>
<xsl:template match="item" mode="div">
<span class="element-{@id}" >
<xsl:value-of select="."/>
</span>
</xsl:template>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question