Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I upgraded Umbraco to 7.1.4 an Archetype to the new 1.2.1 beta. And this snippet stopped working.
@if (fieldset.HasValue("links")) { foreach (var item in fieldset.GetValue<JArray>("links")) { var linkUrl = (item.Value<bool>("isInternal")) ? Umbraco.NiceUrl(item.Value<int>("link")) : item.Value<string>("link"); var linkTarget = item.Value<bool>("newWindow") ? " target=\"_blank\"" : string.Empty; <a class="cf related-link" href="@linkUrl" @Html.Raw(linkTarget)>@(item.Value<string>("title"))</a> } }
On the third line, Umbraco nice url want an int Umbraco.NiceUrl(item.Value<int>("link")) but i get the error
Umbraco.NiceUrl(item.Value<int>("link"))
Input string was not in a correct format
And if i give it a string Umbraco.NiceUrl(item.Value<string>("link")) Umbraco Nice URL says:
Umbraco.NiceUrl(item.Value<string>("link"))
The best overloaded method match for 'Umbraco.Web.UmbracoHelper.NiceUrl(int)' has some invalid arguments
Hi Johan,
Try this:
@foreach (var fieldset in Model.Content.GetPropertyValue<ArchetypeModel>("myarchetype")) { if (fieldset.HasValue("links")) { foreach (var item in fieldset.GetValue<JArray>("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; <li><a class="cf related-link" href="@linkUrl" target="@linkTarget">@(item.Value<string>("caption"))</a></li> } } }
I think it should solve your issue.
Jeavon
Awesome! Webmatrix is whining but it works flawlessly.
<3
Awesome, what does WebMatrix whine about?
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Related links error
I upgraded Umbraco to 7.1.4 an Archetype to the new 1.2.1 beta. And this snippet stopped working.
On the third line, Umbraco nice url want an int
Umbraco.NiceUrl(item.Value<int>("link"))
but i get the errorAnd if i give it a string
Umbraco.NiceUrl(item.Value<string>("link"))
Umbraco Nice URL says:Hi Johan,
Try this:
I think it should solve your issue.
Jeavon
Awesome! Webmatrix is whining but it works flawlessly.
<3
Awesome, what does WebMatrix whine about?
is working on a reply...