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 ListRandom Row DisplayRandom Row Display
Previous
 
Next
New Post
12/12/2008 5:21 PM
 

Is there any way to render data with an xsl file so that it would display just one record randomly? I have 10 records in an udt and I would like it to display just 1 record randomly. Hope that makes sense...

 
New Post
12/13/2008 4:58 PM
 

That one is tricky.

I first thought I need to say "No", because I could not imagine a function which will return a random value - at least inside XSL without EXSLT enhancements or within a dataset expression. But stop: What is random enough is the part of the acesstime within seconds and smaller.

Create a new column with the name Random and Type "Calculated Column" Set the Expression to:

convert((([ticks:now] - [ticks:today]) / 10000), System.Int32)%(count(UserDefinedrowID))+1

This returns a number between 1 and the number of records.

If you now create a custom XSL file with the Token2 XSL Editor, change

    <xsl:variable name="currentData" select="udt:Data" />

to

    <xsl:variable name="random" select="udt:Data[1]/udt:Random" />
    <xsl:variable name="currentData" select="udt:Data[position()=$random]" />

Eureka!

 
New Post
12/15/2008 12:05 PM
 

That would have taken me about a million years to figure out. Thanks so much!

 
New Post
9/5/2011 9:30 PM
 
Hi guys,

How would I create a completely random number (within the range of the number of records) to do as you have done above (new field with a calculated value) to set as the sort order, so that my records are simply displayed in a random order?

Thanks!
 
New Post
12/25/2012 12:12 PM
 
Ky, I know it's been a LONG time since you posted, but a Calculated Column whose expression is "convert([ticks:now]%UserDefinedrowID,System.Int32)" (no quotes) generates a pseudo-random number that you can sort by.
 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsForm and ListForm and ListRandom Row DisplayRandom Row Display


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