you can also just use... www.domain.com/someumbracopage?umbDebugShowTrace=true when you've also set the appkey to true [<add key="umbracoDebugMode" value="true" />]
to see a more descriptive error message. - nicely highlighted in red for the errors.
Ok I got this working, just need to work out one last thing in Razor and i'm done. In the following seciton i need to change the ID of each Slider (see bold), so if there are 4 items back i need to change the id to Slider1, Slider 2, Slider3 etc.
okay geting a little closer...i'm using the index as follows, but i cant get the "slide" text to prefix the @n.index(), tried [email protected]() but no joy...bound to be simple i know...
Still not out of the woods though...i have noticed that the index is starting at 2 then 1 then 3, and i need them to be sequential...does this mean i cannot use Index()?
List blog posts in news rotator
Hey All,
I have the following code which i have adapated from the uBlogsy list posts razor to enable me to show the latest five posts on my home page carousel.
The script is saving without issue and it looks good to me but I'm getting an error on the page:
Error loading MacroEngine script (file: ListHomepageNews.cshtml)
My code is as follows:
@using System.Linq
@using System.Xml.Linq
@using umbraco.MacroEngines
@using uBlogsy.Web.Extensions
@using uBlogsy.Web.Helpers
@{
// get all posts for homepage
IEnumerable<DynamicNode> postList = new DynamicNode(Model.Id)
.AncestorOrSelf(1)
.DescendantsOrSelf("uBlogsyPost")
.Items
.Where(x => x.GetProperty("showOnHomepage").Value != "1");
// get item count
int count = int.Parse(@Parameter.ItemCount);
List<DynamicNode> nodes;
nodes = postList.OrderByDescending(x => x.GetProperty("uBlogsyPostDate").Value)
.Take(count)
.ToList();
<div id="slider">
@foreach (DynamicNode n in nodes)
{
<div id="slide1" class="slide">
<a href="@n.Url">
<span>@n.GetProperty("mainImage").Value</span>
</a>
</div>
}
</div>
<div id="accordion">
@foreach (DynamicNode n in nodes)
{
<div class="link-header">
<a href="@n.Url">
<span>@n.GetProperty("uBlogsyContentTitle").Value</span>
</a>
<div class="link-content">
</div>
</div>
}
</div>
}
Hi Stephen
There is a plugin for Firefox that can assist in debugging your code
https://addons.mozilla.org/EN-us/firefox/addon/umbraco-debug/
Make sure you have the following set in your web.config tho...
<add key="umbracoDebugMode" value="true" />
And then ensure you set it to false when in a live environment
Hope this helps.
Nigel
BTW - man, you are up late...
you can also just use... www.domain.com/someumbracopage?umbDebugShowTrace=true when you've also set the appkey to true [<add key="umbracoDebugMode" value="true" />]
to see a more descriptive error message. - nicely highlighted in red for the errors.
Ha! yes was up way to late...paying for it this morning! Thank you both for the debugging tips...will report back with solution hopefully!
S
wierd, i'm not getting any other descriptive error messges?
Am now sorry! PLease ignore!
Ok I got this working, just need to work out one last thing in Razor and i'm done. In the following seciton i need to change the ID of each Slider (see bold), so if there are 4 items back i need to change the id to Slider1, Slider 2, Slider3 etc.
@foreach (DynamicNode n in nodes)
{
<div id="Slider1" class="slide">
<a href="@n.Url">
<span>@n.GetProperty("uBlogsyContentTitle").Value </span>
</a>
</div>
}
TIA,
S
okay geting a little closer...i'm using the index as follows, but i cant get the "slide" text to prefix the @n.index(), tried [email protected]() but no joy...bound to be simple i know...
<div id="slider">
@foreach (DynamicNode n in nodes)
{
<div id='@n.Index()' class="slide">
<a href="@n.Url">
<img src="/[email protected]("blogmainImage").Value&width=800&height=400&Constrain=True" alt="@n.GetProperty("uBlogsyContentTitle").Value" title="@n.GetProperty("uBlogsyContentTitle").Value" />
</a>
<h2><span>@n.GetProperty("uBlogsyContentTitle").Value</span></h2>
<h3><span>@n.GetProperty("uBlogsyContentTitle").Value</span></h3>
<div class="btnSlider">
<a href="@n.Url" alt="@n.GetProperty("uBlogsyContentTitle").Value" >@n.GetProperty("uBlogsyContentTitle").Value</a>
</div>
</div>
}
</div>
Feel like i'm talking to myself in here...first sign of madness?! :-)
Ok after reading chapter 6 & 7 of the excellent Razor series i worked it out.
<div id="slider">
@foreach (DynamicNode n in nodes)
{
int slidecount = @n.Index();
string cssid = "slide" + slidecount;
<div id='@cssid' class="slide">
<a href="@n.Url">
<img src="/[email protected]("blogmainImage").Value&width=800&height=400&Constrain=True" alt="@n.GetProperty("uBlogsyContentTitle").Value" title="@n.GetProperty("uBlogsyContentTitle").Value" />
</a>
<h2><span>@n.GetProperty("uBlogsyContentTitle").Value</span></h2>
<h3><span>@n.GetProperty("uBlogsyContentTitle").Value</span></h3>
<div class="btnSlider">
<a href="@n.Url" alt="@n.GetProperty("uBlogsyContentTitle").Value" >@n.GetProperty("uBlogsyContentTitle").Value</a>
</div>
</div>
}
</div>
Still not out of the woods though...i have noticed that the index is starting at 2 then 1 then 3, and i need them to be sequential...does this mean i cannot use Index()?
S
Moved this last question into its own post.
S
is working on a reply...