Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Is there any way I can sort / randomise the order of using multiple embedded content tools?
Credit to Gilad for helping me on the previous post.
@using umbraco.MacroEngines;@{ foreach(var testamonial in Model.Children) { var itemsList = testamonial.customerTestimonials; <ul> @foreach(var item in itemsList) { var customerItem = item.customer.InnerText; var testimonItem = item.testimonial.InnerText; <li> <p>@testimonItem</p> <p class="quoter">@customerItem</p> </li> } </ul> }}
I want to randomise the order really, cause its adding in sequence, I have list one, then list twoEffective This is what it looks like the now in the CMSList 1 Items- Item 1.1- Item 1.2- Item 1.3List 2 Items- Item 2.1- Item 2.2
List 3 Items- Item 3.1- Item 3.2
and this razor script would render the list like this.
- Item 1.1- Item 1.2- Item 1.3- Item 2.1- Item 2.2- Item 3.1- Item 3.2
But Ideally I would like it to do this. (pure random)
- Item 2.1- Item 1.1- Item 3.2- Item 3.1- Item 1.3- Item 2.2- Item 1.2
Any ideas?
Try this :
@using umbraco.MacroEngines;@{ List<dynamic> forRandom = new List<dynamic>(); foreach(var testamonial inModel.Children) {var itemsList = testamonial.customerTestimonials; foreach(var item in itemsList) { forRandom.Add(item); } } Random rnd = new Random(); forRandom = forRandom.OrderBy(p => rnd.Next()).ToList(); <ul> @foreach(var item in forRandom) { var customerItem = item.customer.InnerText; var testimonItem = item.testimonial.InnerText; <li> <p>@testimonItem</p> <p class="quoter">@customerItem</p> </li> }</ul>}
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Sorting with the embedded content tool
Is there any way I can sort / randomise the order of using multiple embedded content tools?
Credit to Gilad for helping me on the previous post.
I want to randomise the order really, cause its adding in sequence, I have list one, then list two
Effective This is what it looks like the now in the CMS
List 1 Items
- Item 1.1
- Item 1.2
- Item 1.3
List 2 Items
- Item 2.1
- Item 2.2
List 3 Items
- Item 3.1
- Item 3.2
and this razor script would render the list like this.
- Item 1.1
- Item 1.2
- Item 1.3
- Item 2.1
- Item 2.2
- Item 3.1
- Item 3.2
But Ideally I would like it to do this. (pure random)
- Item 2.1
- Item 1.1
- Item 3.2
- Item 3.1
- Item 1.3
- Item 2.2
- Item 1.2
Any ideas?
Try this :
is working on a reply...