- 46
Hi,
i would like to suggest a way to show RANDOM products,
the only problem in my way i will show below, that i did it for all the carousels, and i did some hard-coded values
so maybe you could implement it in a more correct way.
i added ALL my products to home page feature products,
and in the JCarousel.cshtml i did the following changes -
the code is too long, so i will just show the specific line i changed -
i hope you will implement it,
so i could define if i want a carousel with random or not,
and i hard coded 10 products, so please do it dynamically.
Thanks,
Shay
i would like to suggest a way to show RANDOM products,
the only problem in my way i will show below, that i did it for all the carousels, and i did some hard-coded values
so maybe you could implement it in a more correct way.
i added ALL my products to home page feature products,
and in the JCarousel.cshtml i did the following changes -
the code is too long, so i will just show the specific line i changed -
@if (Model.Items.Count > 0)
{
var RandItemsCount = 10;
var RandItems = Model.Items.OrderBy(x => Guid.NewGuid()).Take(RandItemsCount);
var skin = Model.Settings.Skin;
jQuery('#@carouselHtmlElementId').jcarousel({
vertical: @Model.Settings.CarouselOrientation.ToString(CultureInfo.InvariantCulture).ToLower(),
rtl: @supportRtl.ToString(CultureInfo.InvariantCulture).ToLower(),
start: @Model.Settings.StartIndex,
scroll: @Model.Settings.ScrollItems,
animation: @Html.Raw(animationSpeed),
auto: @Model.Settings.Autoscroll,
size: @RandItemsCount @*@Model.Items.Count*@
<ul id="@carouselHtmlElementId" class="jcarousel-skin-@skin">
@foreach (var item in RandItems @*Model.Items*@)
{
var jCarouselItemWidth = jQuery(jCarouselItem).css('width');
jCarouselItemWidth = jCarouselItemWidth.substring(0, jCarouselItemWidth.length - 2);
var itemsInTheCarousel = @RandItemsCount @*@Model.Items.Count*@;
var totalWidthOfAllItems = jCarouselItemWidth * itemsInTheCarousel;
i hope you will implement it,
so i could define if i want a carousel with random or not,
and i hard coded 10 products, so please do it dynamically.
Thanks,
Shay