Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Paul Stewart 50 posts 71 karma points
    May 08, 2012 @ 16:22
    Paul Stewart
    0

    Sorting Multiple Embedded Contents randomly

    I have multiple embedded contents merged together in one list (lists of testimonials, combined to form one list) and I just want randomise the order of the files. heres my current code. 

    @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>
     }
    }
    Any help would be highly grateful! 
    Paul

  • Paul Stewart 50 posts 71 karma points
    May 09, 2012 @ 12:12
    Paul Stewart
    0

     

    I manage to develop the solution.

    @using umbraco.MacroEngines;
    @{
     if (Model.Where("showTestimonials")) {
        <section class="testimonials">   
        <h2>Testimonials</h2>
     @foreach(var testamonial in Model.NodeById(1140).Children)  {     var itemsList = testamonial.customerTestimonials;         <ul>             @foreach (var item in itemsList)             {                 var customerItem = item.customer.InnerText;                 var testimonItem = item.testimonial.InnerText;
                    int currentNodeInt = Model.Id;                 string showNode = item.alsoShow.InnerText;                 string currentNode = Convert.ToString(currentNodeInt);
                    if (showNode == currentNode                 {             <li>                 <p>@testimonItem</p>                 <p class="quoter">@customerItem</p>             </li>                 }             }         </ul>     }     </section>     } }
Please Sign in or register to post replies

Write your reply to:

Draft