Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Matt 358 posts 841 karma points
    Dec 30, 2022 @ 12:42
    Matt
    0

    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

             @{
        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>
    
  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Dec 30, 2022 @ 13:02
    Huw Reddick
    0

    Are there any errors in the Umbraco logs?

  • Matt 358 posts 841 karma points
    Dec 30, 2022 @ 13:13
    Matt
    0

    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

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Dec 30, 2022 @ 14:00
    Huw Reddick
    100

    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.

    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

Please Sign in or register to post replies

Write your reply to:

Draft