rasmusjp/umbraco-multi-url-picker

Error Within Partial View

Opened this issue · 1 comments

I'm relatively new to advanced backend Umbraco coding, so I'm not too sure what's going on.

The following code is within Nested Content - within Nested Content, if you need me to post the entire file let me know,. but I thought I'd show you the bit where it's going wrong for me.

if(item.HasValue("backgroundPicture") ) {
  var image = item.GetPropertyValue<IPublishedContent>("backgroundPicture");
    <div class="carousel-cell full-width" style="background-image:url('@image.Url');background-color:#@item.GetPropertyValue("backgroundColour"); background-size:cover; background-repeat:no-repeat; background-position:center;">
      <div class="overlay flexbox align-center">
        <div class="content-wrapper">
          @Umbraco.Field(item, "content")
          @{ 
              var buttonItems = item.GetPropertyValue<IEnumerable<IPublishedContent>>("buttons");
              if(buttonItems != null) {
                <div class="flexbox flex-centre buttons-flex">
                  @foreach(var buttonItem in buttonItems) {
                   var UrlPicker = buttonItem.GetPropertyValue<RJP.MultiUrlPicker.Models.Link>("buttonLink");
                     <a href="@Umbraco.Content(UrlPicker).Url" class="button @Umbraco.Field(buttonItem,"buttonColour") @Umbraco.Field(buttonItem, "buttonClass")" >@Umbraco.Field(buttonItem, "buttonText")</a>
                     @Umbraco.Content(UrlPicker).Url
                      }
                </div>
              }
          }
        </div>
      </div>
    </div>
}

All I'm getting is a blank field. I tried using the code suggested in the package readme (below error) but I get this error

'Umbraco.Core.Models.IPublishedContent' does not contain a definition for 'Link' and no extension method 'Link' accepting a first argument of type 'Umbraco.Core.Models.IPublishedContent' could be found (are you missing a using directive or an assembly reference?)

@if(Model.Link != null) { <a href="@Model.Link.Url" target="@Model.Link.Target">@Model.Link.Name</a> }

It's worth noting I won't be able to get this project into Visual Studio, I'm limited to online only.

Any help would be appreciated, I have a very strict deadline!

@timpowersdesign Obviously some time has passed since you posted this. Given it's more of a support question than a bug with the package, in future, you are more likely to get support in the {Our Umbraco forum](https://our.umbraco.com/forum/).

Hopefully you were able to resolve your issue in time for your deadline?
The fix is to use the UrlPicker variable directly, it doesn't need to be passed to the @Umbraco.Content(UrlPicker) function. e.g. @UrlPicker.Url


@rasmusjp I think this one can be closed off.