Related Links in 7.6 RC - List of links is always NULL when an internal link is included
I'm getting an 'object reference not set to an instance of an object' error on the JArray of relatedLinks for a page whenever there is an internal link.
Lists of links that are only external work fine, but if there is just one internal link, the whole array is null.
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@using Newtonsoft.Json.Linq
@{
var query = CurrentPage.AncestorOrSelf(1).DescendantsOrSelf().Where("Visible && DocumentTypeAlias == @0", "newsItem").OrderBy("sortOrder desc");
}
@foreach (var page in query)
{
<h1>@page.Headline</h1>
<p>@page.body</p>
if (page.HasValue("relatedLinks") && page.GetPropertyValue<string>("relatedLinks").Length > 2)
{
var links = page.GetPropertyValue<JArray>("relatedLinks"); // <--- Always null if an internal link is included in the collection of links
foreach (var item in links)
{
var linkUrl = (item.Value<bool>("isInternal")) ? Umbraco.NiceUrl(item.Value<int>("internal")) : item.Value<string>("link");
var linkTarget = item.Value<bool>("newWindow") ? "_blank" : null;
<p><a href="@linkUrl" target="@linkTarget">@(item.Value<string>("caption"))</a></p>
}
}
}
Is this a bug in 7.6 or am I doing something wrong?
If I switch from Typed to Dynamic, I get a completely different problem that I posted about here
Related Links in 7.6 RC - List of links is always NULL when an internal link is included
I'm getting an 'object reference not set to an instance of an object' error on the JArray of relatedLinks for a page whenever there is an internal link.
Lists of links that are only external work fine, but if there is just one internal link, the whole array is null.
Is this a bug in 7.6 or am I doing something wrong?
If I switch from Typed to Dynamic, I get a completely different problem that I posted about here
Thanks!
Hi Josh,
I replied to this in the other thread
Dave
is working on a reply...