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
Hi,
I'm having issues getting getting my URL picker to work, when I add it to my partial view it breaks the page.
Unforently I'm strugling getting any error messages, even adding debug to true I just get "This page isnt working"
This is the code Im struggling with
@{ var links = dashpanel.Value<IEnumerable<Link>>("dashLink"); if (links.Any()) { foreach (var link in links) { <a href="@link.Url" class="dash-div w-inline-block"> } } }
Full code below
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage @using Umbraco.Cms.Core.Models; @{ var dashList = Model.Value<IEnumerable<IPublishedElement>>("dashBoard"); } <div class="grid-wrapper"> <h1 class="heading-10"> Your Dashboard</h1> <div class="dash-column w-row"> @foreach (var dashpanel in dashList.Where(x => x.IsVisible())) { <div class="dash-col w-col w-col-2"> @{ var links = dashpanel.Value<IEnumerable<Link>>("dashLink"); if (links.Any()) { foreach (var link in links) { <a href="@link.Url" class="dash-div w-inline-block"> } } } @{ var dashimage = dashpanel.Value<MediaWithCrops>("dashIcon"); if (dashimage != null) { <img src="@dashimage.MediaUrl()" loading="lazy" width="46" alt="" class="dash-icon"> } } <div class="dash-item-name">@dashpanel.Value("dashItem")</div> </a> </div> } </div> </div>
Are there any errors in the Umbraco logs?
Nope no errors, I think its because of the end of the href tag comes after the code, as if I put the tag inside it works but its not how it should be.
is there a way around this?
Cheers
that would indicate there is something wrong with your code nesting, at a quick glance it is related to your
foreach (var link in links) { <a href="@link.Url" class="dash-div w-inline-block"> }
loop as you are creating a new href for each link, but your closing </a> is outside this loop so is not valid html
</a>
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Issue with URL picker
Hi,
I'm having issues getting getting my URL picker to work, when I add it to my partial view it breaks the page.
Unforently I'm strugling getting any error messages, even adding debug to true I just get "This page isnt working"
This is the code Im struggling with
Full code below
Are there any errors in the Umbraco logs?
Nope no errors, I think its because of the end of the href tag comes after the code, as if I put the tag inside it works but its not how it should be.
is there a way around this?
Cheers
that would indicate there is something wrong with your code nesting, at a quick glance it is related to your
loop as you are creating a new href for each link, but your closing
</a>
is outside this loop so is not valid htmlis working on a reply...