Copied to clipboard

Flag this post as spam?

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


  • Matt 353 posts 825 karma points
    Nov 06, 2019 @ 13:32
    Matt
    0

    Hello,

    I created a doc type without a template, as I didn't really need it. My issue now is when people search the doc type is picked up (which it should) although if you click on the search results it errors as it doesn't have a template to render.

    So I created a template and assigned it to the doc type, gave it some html but now I'm getting an error;

    line 5 - CS0117: 'umbraco.item' does not contain a definition for 'Umbraco'

    Here is my code;

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
        Layout = "Master.cshtml";
    
        var documentPicker = item.Umbraco.Field<IPublishedContent>("documentPicker");
        var linkPicker = item.Umbraco.Field<string>("UrlPicker");
    
    }
    
    @* the fun starts here *@
    
    
    <div class="body-section">
        <div class="body-container w-container">
          <div class="w-richtext">
    
    <div class="guidandpolicies-wrapper">
            <div class="w-row">
                <div class="w-col w-col-2">
                    @{
                        if (documentPicker != null)
                        {
                            <a href="@documentPicker.Url" target="_blank" class="document-link-block w-inline-block"><img src="~/images/policies_image.png"></a>
                        }else if(!string.IsNullOrEmpty(linkPicker)){
                        <a href="@linkPicker" target="_blank" class="document-link-block w-inline-block"><img src="~/images/policies_image.png"></a>
    
                                }
                    }
                </div>
                <div class="w-col w-col-10">
                    <div class="guidanceandpolicies-info-div">
                        <h5 class="gnp-title">
                            @{
                                if (documentPicker != null)
                                {
                                    <a href="@documentPicker.Url" target="_blank" class="document-link-text">@Umbraco.Field("documentTitle")</a>
                                }else if(!string.IsNullOrEmpty(linkPicker)){
                                <a href="@linkPicker" target="_blank" class="document-link-text">@Umbraco.Field("documentTitle")</a>
                                }
                            }
                        </h5>
                        <div class="gnp-document-info">@Umbraco.Field("documentDescription")</div>
                    </div>
                </div>
            </div>
        </div>
    
    
    
          </div>
        </div>
      </div>
    

    Any help would be great.

  • Matt 353 posts 825 karma points
    Nov 07, 2019 @ 11:19
    Matt
    1
       var documentPicker = item.Umbraco.Field<IPublishedContent>("documentPicker");
    

    to

    var documentPicker = Model.Content.GetPropertyValue<IPublishedContent>("documentPicker");
    

    Resolved it.

Please Sign in or register to post replies

Write your reply to:

Draft