I already looked at that solution but i couldn't figure it out. Now with a fresh look i made it work!
This is the working code btw:
@{
var topNode = Model.AncestorOrSelf(1);
var nodes = new DynamicNodeList();
foreach(var referenceItem in topNode.referencesPicker){
var n = new DynamicNode(referenceItem.InnerText);
nodes.Add(n);
}
foreach (dynamic reference in nodes.Random(1))
{
Get single random node from MNTP
Hi Guys,
The title actually explains my issue but what i want is to display 1 Random node from multiple nodes i have selected with the MNTP.
With this code i'm getting all the node (id's) and returning the property's in it, so that part works fine. Just want to display 1 randomly.
Chris
Hi Chris
should work for you.
G
Hi Gary,
I think that's not going to work. Getting syntax error on that. If i write it down this way:
I get this error: 'umbraco.MacroEngines.DynamicXml' does not contain a definition for 'Random'
any suggestions?
Ah
The MNTP throws that one!
Found this answer here which you should be able to adapt if it doesn't work directly - it explains how it works.
http://our.umbraco.org/forum/developers/razor/22237-Random-uComponents-Multi-Node-Tree-Picker
Hope it helps G
Hi Gary,
I already looked at that solution but i couldn't figure it out. Now with a fresh look i made it work!
This is the working code btw:
@reference.referenceName
@reference.referenceOneliner @reference.referenceText } }
Thanks!
is working on a reply...