Related Links data type | Null reference when selecting internal umbraco page
Hi All,
I have used the related link data type on multiple projects and have had never had any issues until now. I have recently installed Umbraco version 7.7.2 assembly: 1.0.6484.21641 and use the following (cut down version) code to display a link specified in the back office
@{
var siteRoot = Model.Content.AncestorOrSelf("homePage");
var carouselLandingPage = siteRoot.Descendant("carouselLandingPage");
}
<div class="carousel-inner text-center">
@foreach (var carouselSlide in carouselLandingPage.Children)
{
foreach (var link in carouselSlide.GetPropertyValue<JArray>("buttonLink"))
{
var linkUrl = (link.Value<bool>("isInternal")) ? Umbraco.NiceUrl(link.Value<int>("internal")) : link.Value<string>("link");
var linkTarget = link.Value<bool>("newWindow") ? "_blank" : null;
<p class="slide-btn">
<a title="@(link.Value<string>("caption"))" href="@linkUrl" target="@linkTarget" class="btn btn-white btn-lg">@(link.Value<string>("caption"))</a>
</p>
}
}
</ul>
</div>
</div>
</div>
}
</div>
Whenever i specifiy an internal umbraco page i get the following
However, when i specify an external link (see below) there is no problems and everything works perfectly
Just to follow up i implemented the code from the link Barry provided (https://our.umbraco.org/documentation/getting-started/backoffice/property-editors/built-in-property-editors/Related-Links2) and this now works as expected.
Couple of points
Ensure the following is true EnablePropertyValueConverters (found in umbracoSettings.config)
add the following using statement @using Umbraco.Web.Models
Related Links data type | Null reference when selecting internal umbraco page
Hi All,
I have used the related link data type on multiple projects and have had never had any issues until now. I have recently installed Umbraco version 7.7.2 assembly: 1.0.6484.21641 and use the following (cut down version) code to display a link specified in the back office
Whenever i specifiy an internal umbraco page i get the following
However, when i specify an external link (see below) there is no problems and everything works perfectly
Is this a bug or is there an issue with something im doing? I have used this code (taken from https://our.umbraco.org/documentation/getting-started/backoffice/property-editors/built-in-property-editors/related-links) on multiple projects and never had an issue before?
Thanks Paul
Hi Paul,
As the link to that property editor says, that type is now obsolete. Refactor your code to the updated Related Link type as found here:
https://our.umbraco.org/documentation/getting-started/backoffice/property-editors/built-in-property-editors/Related-Links2
HI Barry,
Thanks for responding!
Thanks a very good point, totally missed the 'H1' obselete info :)!
Ill refactor my code using the link you provided.
Thanks Paul
Hi guys,
Just to follow up i implemented the code from the link Barry provided (https://our.umbraco.org/documentation/getting-started/backoffice/property-editors/built-in-property-editors/Related-Links2) and this now works as expected.
Couple of points
Final Code
Thanks Paul
is working on a reply...