Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error Within Partial View #66

Open
timpowersdesign opened this issue Nov 27, 2017 · 1 comment
Open

Error Within Partial View #66

timpowersdesign opened this issue Nov 27, 2017 · 1 comment

Comments

@timpowersdesign
Copy link

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!

@leekelleher
Copy link
Contributor

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants