I have a page with a content picker as one of the doc types.
I am using an if/else statement to test if content has been picked. If no content has been picked then I get an error. I've seen some other posts about this but none of the solutions help me. thanks for your help
here is the code
@inherits Umbraco.Web.Mvc.UmbracoViewPage<LiveOnTheLine>
@{
Layout = "Master.cshtml";
}
@{
var nextStream = Model.OnNext;
var thisNextStream = nextStream.GetPropertyValue("streamProgram") as Program;
var nowShowing = Model.NowShowing;
var thisNowShowing = nowShowing.GetPropertyValue("streamProgram") as Program;
var noNow = Model.GetPropertyValue<IPublishedContent>("nowShowing");
}
<section class="grid-container py24 md:py48">
<div class="grid-x grid-padding-x grid-margin-x align-center" >
<div class="cell medium-6 text-center">
<div class="grid-x align-center">
<h3 class="heading mb16 vlarge">Streaming Now</h3>
@if ((Model.NowShowing != null) && (Model.NowShowing.ToString() != ""))
{
<div class="cell lotl-bg-img" style="background-image: url('@thisNowShowing.HeadingHeroImage.Url')">
</div>
<div class="cell up small-10 px32 py32 md:px48 md:py48 lw-bg-yellow">
<h4 class="">@thisNowShowing.SmallTitle</h4>
<p>10AM, Friday 23rd October</p>
<a class="button my16" href="@nowShowing.Url">Watch Now</a>
</div>
}
else
{
<div class="cell lotl-bg-img" >
</div>
<div class="cell small-10 px32 py32 md:px48 md:py48 lw-bg-yellow">
<h4 class="">Nothing is currently streaming</h4>
<a class="button my16" href="#online-program">View online program</a>
</div>
}
</div>
Any insight about how to get this working would be great. I've been trying for hours now and I just can not work it out
Aucun commentaire:
Enregistrer un commentaire