I have looked into your code the only thing that I think that´s wrong with your code is that you have the @ in front of your if statments. You are in a foreach loop, so the Razor engine is started, so to say.
So try this snippet of code and see if it works for you.
@inherits Umbraco.Web.Macros.PartialViewMacroPage @{ var sliderItems = Umbraco.Content(5021); var magazineLevel = CurrentPage.DescendantsOrSelf("Magazine").OrderBy("magazineDate desc, magazineDate"); var latestMagazine = magazineLevel.Take(1);
Good it got solved - As mentiond in my initial comment you can always check the trace-log to get some more useful descriptions of the error messages so you may be able to figure it out next time by having a look :)
Trying to fix this razor view
Hey guys,
Im having some trouble getting this code to work. Can anyone see why its not working?
@inherits Umbraco.Web.Macros.PartialViewMacroPage @{ var sliderItems = Umbraco.Content(5021); var magazineLevel = CurrentPage.DescendantsOrSelf("Magazine").OrderBy("magazineDate desc, magazineDate"); var latestMagazine = magazineLevel.Take(1); <div class="container-fluid"> <div class="row-fluid"> <div class="carousel slide" id="myCarousel" data-ride="carousel"> <ol class="carousel-indicators"> <li data-target="#myCarousel" data-slide-to="0" class="active"></li> <li data-target="#myCarousel" data-slide-to="1"></li> </ol> <div class="carousel-inner"> <ul class="thumbnails"> @foreach (var item in sliderItems.Children.OrderBy("Id desc")) { @if (item.HasValue("frontpageSliderItemArticleOneId")) { var article = Umbraco.Content(item.frontpageSliderItemArticleOneId); var articleImage = Umbraco.Media(article.homepageArticleImage); <li> <div class="thumbnail" id="magazineSliderSmall"> <div class="articleTitle"> <span class="title"><p><a href="@article.Url">@article.homepageArticleTitle</a></p></span> </div> <div class="artPic"> <a href="@article.Url"> <img style="height: 111px; width: 311px;" src="@articleImage.umbracoFile" alt=""> </a> </div> </div> </li> } @if (item.HasValue("frontpageSliderItemArticleTwoId")) { var article = Umbraco.Content(item.frontpageSliderItemArticleOneId); var articleImage = Umbraco.Media(article.homepageArticleImage); <li> <div class="thumbnail" id="magazineSliderSmallMid"> <div class="articleTitle"> <span class="title"><p><a href="@article.Url">@article.homepageArticleTitle</a></p></span> </div> <div class="artPic"> <a href="@article.Url"> <img style="height: 111px; width: 311px;" src="@articleImage.umbracoFile" alt=""> </a> </div> </div> </li> } @if (item.HasValue("frontpageSliderItemArticleThreeId")) { var article = Umbraco.Content(item.frontpageSliderItemArticleOneId); var articleImage = Umbraco.Media(article.homepageArticleImage); <li> <div class="thumbnail" id="magazineSliderSmall"> <div class="articleTitle"> <span class="title"><p><a href="@article.Url">@article.homepageArticleTitle</a></p></span> </div> <div class="artPic"> <a href="@article.Url"> <img style="height: 111px; width: 311px;" src="@articleImage.umbracoFile" alt=""> </a> </div> </div> </li> } } </div> </ul> </div> <a data-slide="prev" href="#myCarousel" class="left carousel-control">‹</a> <a data-slide="next" href="#myCarousel" class="right carousel-control">›</a> </div> </div> </div> }Hi Nicolai
Could you please check the /App_Data/Logs file and see if anything marked with ERROR provides some more useful information about the error?
And does Visual Studio provide any hints about the issue if you're a VS guy?
/Jan
Hi Nicolai,
I have looked into your code the only thing that I think that´s wrong with your code is that you have the @ in front of your if statments. You are in a foreach loop, so the Razor engine is started, so to say.
So try this snippet of code and see if it works for you.
/Dennis
You're right Dennis. I totally blanked out on that one :) Thanks alot!
Hi Nicolai
Good it got solved - As mentiond in my initial comment you can always check the trace-log to get some more useful descriptions of the error messages so you may be able to figure it out next time by having a look :)
Have a nice day.
/Jan
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.