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
So im trying to use the MUP in a navigation to let the editor add external links to a nav. I have the nav in a partial.
Im basically doing this:
@inherits Umbraco.Web.Mvc.UmbracoViewPage @using Umbraco.Web --- @foreach (var item in menuPages) { var myLink = item.Value<Link>("theLink"); @if (myLink != null) { <a href="myLink.Url">@item.Name</a> } else { <a href="@item.Url">@item.Name</a> } }
but it doesn't work. Doing "item.Value("theLink")" without returns the error "cannot convert from 'method group' to 'HelperResult'"
Hi,
How many items do you have selected in the MUP? If you have selected few items use this code -
var links = Model.Value<IEnumerable<Link>>("footerLinks");
If Max number of items is configured to 1
var link = Model.Value<Link>("link");
There is a difference in one or few Links
Thanks,
Alex
Maybe the issue is in this piece of code? =
@if (myLink != null) { <a href="myLink.Url">@item.Name</a> } else { <a href="@item.Url">@item.Name</a> }
probably it should be:
@if (myLink != null) { <a href="@myLink.Url">@item.Name</a> }
hehe yeah, that would fix the href for sure :)
The problem is it never gets that far, as the if statement "@if (myLink != null)" is never true. Even if links are defined...
There are only 2 things that can be wrong - property alias "theLink" or the type "Link"
Can you check both?
And if all of these are correct - then I would recommend you to debug the code and check what value exactly is stored in item.Value("theLink")?
"item.Value("theLink")" returns "Umbraco.Web.Models.Link"
Please note that im using "@using Umbraco.Web" where the documentation uses "@using Umbraco.Web.Models"
Try this code:
item.Value<Umbraco.Web.Models.Link>
SUCCES! thanks a lot.
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.
Continue discussion
multi url picker in 8.6
So im trying to use the MUP in a navigation to let the editor add external links to a nav. I have the nav in a partial.
Im basically doing this:
but it doesn't work. Doing "item.Value("theLink")" without returns the error "cannot convert from 'method group' to 'HelperResult'"
Hi,
How many items do you have selected in the MUP? If you have selected few items use this code -
If Max number of items is configured to 1
There is a difference in one or few Links
Thanks,
Alex
Maybe the issue is in this piece of code? =
probably it should be:
hehe yeah, that would fix the href for sure :)
The problem is it never gets that far, as the if statement "@if (myLink != null)" is never true. Even if links are defined...
There are only 2 things that can be wrong - property alias "theLink" or the type "Link"
Can you check both?
And if all of these are correct - then I would recommend you to debug the code and check what value exactly is stored in item.Value("theLink")?
"item.Value("theLink")" returns "Umbraco.Web.Models.Link"
Please note that im using "@using Umbraco.Web" where the documentation uses "@using Umbraco.Web.Models"
Try this code:
SUCCES! thanks a lot.
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.