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'm having an issue where I have nested content that contains a multi-node picker that is has a maximum number of items is set to 1.
I'm trying the following, but the link won't show because I think it returns a null even when I have published links in the content.
<!-- Features --> @{ var features = Model.Value<IEnumerable<IPublishedElement>>("productFeatureList"); <section class="container mb-3 mt-3"> <div class="row pb-4"> @foreach (var feature in features) { <div class="col-lg-4 col-sm-6 mb-30 pb-4"> <div class="card"> <div class="card-body"> <h4 class="card-title">@feature.GetProperty("featureBenefit").Value()</h4> <p class="card-text">@feature.GetProperty("featureDescription").Value()</p> @{ var moreLink = feature.Value<IPublishedContent>("featureMoreLink");} @if (moreLink != null) { <a href="@moreLink.Url" class="btn btn-gradient mt-2">@moreLink.Name</a> } </div> </div> </div> } </div> </section> }
Hi,
Have you tried to get the raw value to see what is stored in "featureMoreLink"?
Just use feautre.Value("featureMoreLink"), maybe like this:
feautre.Value("featureMoreLink")
@if (moreLink != null) { <a href="@moreLink.Url" class="btn btn-gradient mt-2">@moreLink.Name</a> } else { <text>@feautre.Value("featureMoreLink")</text> }
Thanks for the suggestion. I tried it out with the code below and it definitely displays the results of the "else" part of the statement as: Umbraco.Web.Models.Link
I'm not sure what do next.
@{ var moreLink = feature.Value<IPublishedContent>("featureMoreLink");} @if (moreLink != null) { <a href="@moreLink.Url" class="btn btn-gradient mt-2"><i class="[email protected]("fontIcon").Value()"></i> @moreLink.Name</a> } else { @feature.Value("featureMoreLink") }
This makes sense :)
I can't say why your multi-node picker stores a Link (sure it's not a multiurlpicker?), but if you change the type, it should work:
@{ var moreLink = feature.Value<Umbraco.Web.Models.Link>("featureMoreLink");} var fontIcon = feature.Value<string>("fontIcon"); if (moreLink != null) { <a href="@moreLink.Url" class="btn btn-gradient mt-2"><i class="fe-icon-@fontIcon"></i> @moreLink.Name</a> } }
It is a Multi Url Picker. Your help did the trick. I'm still learning how to change the type on things, so I needed an example like that.
Here's the final code that worked:
<!-- Features --> @{ var features = Model.Value<IEnumerable<IPublishedElement>>("productFeatureList"); <div class="row pb-2 pt-4"> @foreach (var feature in features) { <div class="col-lg-4 col-sm-6 mb-30 pb-4 d-flex align-items-stretch"> <div class="card"> <div class="card-body"> <h4 class="card-title">@feature.GetProperty("featureBenefit").Value()</h4> <p class="card-text">@feature.GetProperty("featureDescription").Value()</p> @{ var moreLink = feature.Value<Umbraco.Web.Models.Link>("featureMoreLink"); } @if (moreLink != null) { <a href="@moreLink.Url" class="btn btn-gradient mt-2"><i class="[email protected]("fontIcon").Value()"></i> @moreLink.Name</a> } </div> </div> </div> } </div> }
We are all still learning ;-)
Happy I was able to help
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
How to make Multi-Url Picker work in Nested Content
I'm having an issue where I have nested content that contains a multi-node picker that is has a maximum number of items is set to 1.
I'm trying the following, but the link won't show because I think it returns a null even when I have published links in the content.
Hi,
Have you tried to get the raw value to see what is stored in "featureMoreLink"?
Just use
feautre.Value("featureMoreLink")
, maybe like this:Thanks for the suggestion. I tried it out with the code below and it definitely displays the results of the "else" part of the statement as: Umbraco.Web.Models.Link
I'm not sure what do next.
This makes sense :)
I can't say why your multi-node picker stores a Link (sure it's not a multiurlpicker?), but if you change the type, it should work:
It is a Multi Url Picker. Your help did the trick. I'm still learning how to change the type on things, so I needed an example like that.
Here's the final code that worked:
We are all still learning ;-)
Happy I was able to help
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.