Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsForm and ListForm and ListWrapping every X items with a divWrapping every X items with a div
Previous
 
Next
New Post
10/27/2011 10:25 AM
 
We're trying what should be a simple thing, wrapping every 2 items with a DIV tag. I found a good example here:

http://stackoverflow.com/questions/5604726/xslt-how-can-i-wrap-each-3-elements-by-div
(See the second answer, it's more elegant.)

And I was able to implement this, almost to perfection. The one problem I am having is my targeting of "match='/'". When target that broadly, it returns the Data elements and the Field elements. When I use the following, it returns nothing. How can I adjust my queries to get just the data I need?

01.<xsl:variable name="group" select="2" />
02.<xsl:template match="udt:UserDefinedTable">
03.  <xsl:apply-templates
04.      select="udt:UserDefinedTable/Data[position() mod $group = 1]" />
05.</xsl:template>
06. 
07.<xsl:template match="udt:Data" mode="inner">
08.  <section class="column">
09.    <a href="link" class="mastermind-group">
10.      <h2>
11.        <xsl:value-of select="udt:Headline" disable-output-escaping="yes" />:
12.      </h2>
13.      <p>
14.        <strong>
15.          <xsl:value-of select="udt:Subhead" disable-output-escaping="yes" />
16.        </strong>
17.      </p>
18.      <img alt="" src="/portals/quantumclub/images/qc-mastermind-group.png" width="183" height="161" class="right" />
19.      <p>
20.        <xsl:value-of select="udt:Body" disable-output-escaping="yes" />
21.        <span class="more">Learn more</span>
22.      </p>
23.    </a>
24.  </section>
25.</xsl:template>
26. 
27.<xsl:template match="udt:Data">
28.  <xsl:variable name="currentData" select=".|following-sibling::udt:Data[position() < $group]" />
29.  <div class="grid2col">
30.    <xsl:apply-templates
31.        select="$currentData"
32.        mode="inner" />
33.  </div>
34.</xsl:template>


This is just the key portion of the XSL. (Removed the standard headers and edit link for brevity.)

Thanks for your input
 
New Post
10/27/2011 11:44 AM
 
Hi Lucas,
your script in line 4 misses a udt: in front of Data:
select="udt:UserDefinedTable/udt:Data[position() mod $group = 1]" />
 
New Post
10/27/2011 12:08 PM
 
Good find, thanks, it works now!
 
New Post
10/27/2011 12:28 PM
 
Ok, quick follow-up question. When using the following-sibling selector, it seems problematic to sort the data. Is there a good way, with XSLT 1.0, to run a sort against this list? I've created an integer column named "Sort"
 
New Post
10/27/2011 12:38 PM
 
Nevermind, it looks like the module has its own sorting options, perfect!
 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsForm and ListForm and ListWrapping every X items with a divWrapping every X items with a div


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out