Copied to clipboard

Flag this post as spam?

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


  • Matt 202 posts 517 karma points
    Jan 08, 2019 @ 10:48
    Matt
    0

    Code not working for media picker

    Hello all,

    I have the follow code;

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage<ContentModels.GuideList>
    @using ContentModels = Umbraco.Web.PublishedContentModels;
    @{
        Layout = "Master.cshtml";
    }
    
      <div class="body-section">
        <div class="body-container w-container">
          <h1 class="home-page-heading">@Model.Content.Name</h1>
    
    @foreach(var pDocument in Model.Content.Children())
      {
      var documentPicker = item.GetPropertyValue<IPublishedContent>("documentPicker");
    
                      <div class="faq-wrapper">
              <div class="guidandpolicies-wrapper">
                <div class="w-row">
                  <div class="w-col w-col-2">
                      @{
        if (documentPicker != null)
        {
             <a href="@documentPicker.Url" class="document-link-block w-inline-block"><img src="/images/policies_image_1policies_image.png" alt=""></a>
        }
    }   
                      </div>
                  <div class="w-col w-col-10">
                    <div class="guidanceandpolicies-info-div">
                      <h5 class="gnp-title"><a href="@pDocument.Url" class="document-link-text">@pDocument.Name</a></h5>
                      <div class="gnp-document-info">This is some text inside of a div block, document description here.</div>
                    </div>
                  </div>
                </div>
                </div>
          </div>
      }      
        </div>
      </div>
    

    All I want to do is get the pdf document which I upload to show on my page, I used the media picker code but for some reason I'm getting the following error;

    Compiler Error Message: CS0117: 'umbraco.item' does not contain a definition for 'GetPropertyValue'

    Line 13: var documentPicker = item.GetPropertyValue

    Thanks in advance, Matt

  • Dan Diplo 1459 posts 5623 karma points MVP 3x c-trib
    Jan 08, 2019 @ 11:05
    Dan Diplo
    0

    What is item in this context? Are you, perhaps, intending to access the pDocument variable (in your loop) instead?

    ie. you need to do:

    var documentPicker = pDocument.GetPropertyValue<IPublishedContent>("documentPicker");
    
Please Sign in or register to post replies

Write your reply to:

Draft