Copied to clipboard

Flag this post as spam?

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


  • rehamhabbas 14 posts 103 karma points
    Jun 13, 2018 @ 12:08
    rehamhabbas
    0

    Nested Content in partial view

    Hello This error come to the front end When I try to print nested content in a partial view. Umbraco.Web.Models.DetachedPublishedContent' does not contain a definition for 'GetPropertyValue'

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    
    @{
        var ClientPage = Umbraco.Content(1151);
        string lang = Request.RawUrl.ToString().Contains("/en/") ? "en" : "ar";
        string locale = lang == "ar" ? "Arabic" : "English";
        var setCulture = lang == "en" ? "en-Us" : "ar-SA";
        Culture = UICulture = setCulture;
    }
    
    @{
    
        var clientsList = ClientPage.clients;
    
        if (clientsList != null)
        {
            foreach (var client in clientsList)
            {
                var clientImage = client.GetPropertyValue<IPublishedContent>("logo");
                IPublishedContent category = client.GetPropertyValue<IEnumerable<IPublishedContent>>("category").First();
    
                //@umbraco.library.GetPreValueAsString(@client.GetPropertyValue("categoryEn"))
    
                <div class='col-md-3 col-sm-4 col-xs-6 text-center scale-anm @category["code"] all'>
                    <div class="client-img-container  d-flix justify-content-center align-items-center">
                        <img src=" @clientImage.Url" alt=''>
                    </div>
                </div>
            }
        }
    }
    

    enter image description here

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Jun 13, 2018 @ 20:24
    Alex Skrypnyk
    1

    Hi Reham

    Can you use this code:

    @{
        var ClientPage = Umbraco.TypedContent(1151);
        string lang = Request.RawUrl.ToString().Contains("/en/") ? "en" : "ar";
        string locale = lang == "ar" ? "Arabic" : "English";
        var setCulture = lang == "en" ? "en-Us" : "ar-SA";
        Culture = UICulture = setCulture;
    }
    
    @{
    
        var clientsList = ClientPage.GetPropertyValue<IEnumerable<IPublishedContent>>("clients");
    
        if (clientsList != null)
        {
    
  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Jun 13, 2018 @ 20:24
    Alex Skrypnyk
    1
    var ClientPage = Umbraco.TypedContent(1151);
    

    instead of

    var ClientPage = Umbraco.Content(1151);
    
  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Jun 13, 2018 @ 20:25
    Alex Skrypnyk
    1
    var clientsList = ClientPage.GetPropertyValue<IEnumerable<IPublishedContent>>("clients");
    

    instead of:

    var clientsList = ClientPage.clients;
    
Please Sign in or register to post replies

Write your reply to:

Draft