Copied to clipboard

Flag this post as spam?

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


  • Kristian Overgaard 22 posts 185 karma points notactivated
    Oct 04, 2019 @ 11:04
    Kristian Overgaard
    0

    Custom properties are empty

    I have an issue with getting the values of custom properties, after retrieving an IPublishedContent with a specific culture.

    I have a workaround for it right now, but there should be a better way of handling it.

    I have a Surfacecontroller that looks something like this:

    public ActionResult Filter(int id, string json)
        {
            var page = Umbraco.Content(id);
    
            var culture = "da";
    
            HomePage homePage = new HomePage(page);
    
            var MyClasses = (IEnumerable<IPublishedContent>)homePage.Value("MyCustomListProperty",culture);
    
            foreach(var myClass in MyClasses){
    
                var prop = myClass.CustomProperty; //this gives the value from the default culture
                var propReal = myClass.Value("CustomProperty",culture);//This gives the correct value
            }
    ...
    }
    

    i can get the correct prop value using myClass.value and provide the culture, but that should be redundant as i retrieved the list specifying the culture. I', certain this has worked before, where "prop" would get the real value, but can't figure out how or why it stopped working.

    Any help on why the properties behave like this ?

Please Sign in or register to post replies

Write your reply to:

Draft