Show multiple random references Options
squiggle
Posted: Sunday, February 24, 2008 9:53:29 PM
Rank: Newbie

Joined: 2/24/2008
Posts: 1
Hi,

I've searched the forum on this topic without any luck, so here goes:

How do I randomly select 3-4 references to show on the front page and change them on every reload? And is't possible to choose the references from 2 different folders?

Hope someone can help me with this - I've search without luck for quit a while now.
drobar
Posted: Sunday, February 24, 2008 10:45:09 PM

Rank: Umbracoholic

Joined: 9/8/2006
Posts: 1,698
Location: KY, USA
Hi, Marianne,

I know I've answered this before but I can't find it at the moment. Perhaps these posts will give you enough to get started.

Basically, there are two things you'll need to handle. First is selecting a random node. Since XSLT doesn't know about "random", you'll need a helper function. This can be done with exslt's math functions or you can write your own in-line javascript or c# function. Both methods are shown in these examples.

http://forum.umbraco.org/20241


The second thing is to merge the results from two different sources and select a number of random items from between them. The easiest way to do that is to select ALL the nodes from the tree that meet your criteria all at one time, rather than trying to merge two different results. To do this, you'll need to flag where to find the references. If you have a unique docType, that makes it very easy. If not, you'll probably want to use the nodeid of the folders that contain your references.

cheers,
doug.



MVP 2007-2009 - Official Umbraco Trainer for North America - Percipient Studios
neehouse
Posted: Monday, February 25, 2008 4:09:16 AM

Rank: Umbracoholic

Joined: 7/20/2006
Posts: 1,074
Location: Charleston, West Virginia, United States
To correct Doug on one matter, you can't use Javascript in v3. If you do, you will likely max the cpu on the system you try to run it on.

• 2007/2008 MVP • 2008/2009 MVP • Certified • Licensing • Support • Development • Hosting •
Jasko
Posted: Monday, February 25, 2008 2:25:49 PM
Rank: Devotee

Joined: 12/11/2006
Posts: 47
Hey Marianne,

If you find a solution I would be very interested in hearing about. I am sitting in the same situation as you :)

/Jan
Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.