I'm having a bit of an issue trying to get the url of a content picker datatype to output within a loop - the old dynamic version in 7.5 doesn't work anymore in 7.6:
@{
var selection = Model.Content.Site().FirstChild("SlideshowRepository").Children<Slide>()
.Where(x => x.IsVisible());
}
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
@foreach (var item in selection)
{
<div class="item @item.IsFirst("active")">
<div class="fill" style="background: url(@item.BackgroundImage.Url) center bottom / cover no-repeat scroll;"></div>
<div class="carousel-caption carousel-caption-centre">
<div class="row">
<div class="col-sm-5">
<h2>@Html.Raw(item.GetPropertyValue("Title"))</h2>
<p>@item.IntroText</p>
// THIS IS THE OLD BIT THAT ISN'T WORKING
@if (item.HasValue("SlideLink"))
{
<p><a class="btn btn-lg btn-primary" href="@Umbraco.Content(item.SlideLink).Url" role="button">Learn More</a></p>
}
</div>
<div class="col-sm-7">
@if (item.HasValue("Image"))
{
<img src="@item.Image.Url" class="img-responsive slideshow">
}
</div>
</div>
</div>
</div>
}
</div>
<div class="container">
<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
This is probably a really simple thing to do - but i just can't figure it out.
Content Picker URL output in loop
Morning folks,
I'm having a bit of an issue trying to get the url of a content picker datatype to output within a loop - the old dynamic version in 7.5 doesn't work anymore in 7.6:
This is probably a really simple thing to do - but i just can't figure it out.
Thanks Darren
Hi Darren
It should work:
What line causes the problem?
SlideLink is the Content Picker Datatype - this doesn't produce anything. Using @item.Slidelink.Url produces a YSOD saying Slidelink is not defined.
Cheers Darren
Hi Darren
What about this code:
Thanks,
Alex
Thanks Alex, I'll give this a go!
Cheers Alex - works! Marked it as solution...
You are welcome, Darren, glad to help.
Alex
is working on a reply...