Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
47 lines (43 sloc) 2.2 KB
@inherits UmbracoViewPage
@using ContentModels = Umbraco.Web.PublishedModels;
@using Umbraco.Web.Models
@{
string carouselId = "mainCarousel";
var carousel = Model.Value<IEnumerable<IPublishedElement>>(carouselId);
}
@if (carousel != null && carousel.Any())
{
<div class="carousel slide" data-ride="carousel" id="@carouselId">
<div class="carousel-inner" role="listbox">
@{
int slideCount = 0;
foreach (var slide in carousel)
{
string title = slide.Value<string>("slideTitle");
string subtitle = slide.HasValue("slideSubtitle") ? slide.Value<string>("slideSubtitle") : "";
string imageUrl = slide.Value<IPublishedContent>("slideImage")?.GetCropUrl(1920,1080) ?? "/img/carousel.jpg";
IEnumerable<Link> links = slide.Value<IEnumerable<Link>>("slideLink");
Link link = links != null ? links.FirstOrDefault() : null;
<div class="item @(slideCount == 0 ? "active" : "")">
<div class="jumbotron carousel-hero" style="background-image:url('@(imageUrl)');">
<h1 class="hero-title">@title</h1>
<p class="hero-subtitle">@subtitle</p>
<p><a class="btn btn-primary btn-lg hero-button" role="button" target="@link.Target" href="@link.Url">@link.Name</a></p>
</div>
</div>
slideCount++;
}
}
</div>
<div>
<a class="left carousel-control" href="#@carouselId" role="button" data-slide="prev"><i class="glyphicon glyphicon-chevron-left"></i><span class="sr-only">Previous</span></a>
<a class="right carousel-control" href="#@carouselId" role="button" data-slide="next"><i class="glyphicon glyphicon-chevron-right"></i><span class="sr-only">Next</span></a>
</div>
<ol class="carousel-indicators">
@for (int i = 0; i < slideCount; i++)
{
<li data-target="#@carouselId" data-slide-to="@i" class="@(i == 0 ? "active" : null)"></li>
}
</ol>
</div>
}
You can’t perform that action at this time.