I have a portfolio in the website and on the homepage there are 6 logo's displayed in a row. They will be random displayed. But now i get only the first 6 random displayed and let say the 7th item will not be shown at all. How can i manage to randomly display all the items but only show 6 of them...
The code:
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{
var homePage = CurrentPage.AncestorsOrSelf(1).First();
var sliderOverview = homePage.OurWork.First();
var contentSliders = sliderOverview.Section;
}
<div class="row">
@foreach(var slide in contentSliders.Take(6).RandomOrder())
{
if (slide.HasValue("customerLogo"))
{
var mediaFile = Umbraco.Media(slide.customerLogo);
<div class="col-md-2 col-sm-4 col-xs-6">
<div class="ourWorkImg">
<img class="lazy" data-original="/[email protected]&Compression=100&width=130&height=100&constrain=true">
</div>
</div>
}
}
<div class="clearfix"></div>
</div>
Random all childs
Hi there,
I have a portfolio in the website and on the homepage there are 6 logo's displayed in a row. They will be random displayed. But now i get only the first 6 random displayed and let say the 7th item will not be shown at all. How can i manage to randomly display all the items but only show 6 of them...
The code:
Kind regards, Robert
Hi Robert,
this is behave logically.
You take 6 items in contentSliders and after this you randomize the items.
Change the position of "Take" and "RandomOrder" in your foreach to:
Hope this helps.
Best,
Sören
Hi Sören,
Ah that sounds logical :)
Thank you! Works perfect!
Kind regards, Robert
is working on a reply...