Copied to clipboard

Flag this post as spam?

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


  • Daniel 22 posts 214 karma points
    May 11, 2017 @ 00:00
    Daniel
    0

    GetProperty won't return value.

         foreach (var post in Model.Children<PostModel>())
                {
    
                               if(post.GetProperty("featuredPost").Value.ToString() == "false")
                                {
                                <h1 class="post-title"><a href="@post.Url">Featured Post</a></h1>
                                }
    
    -- More code
                 }
    

    Alright so, I have the code above (using Articulate) and I have an Umbraco property called featuredPost on every post. I am trying to get the value and if it is true I want it to show on the post that has that value set to true.

    I've been trying it that way but it is not working, I checked the name of the property and it seems fine, I might be wrong on the if using "post" as the variable.

    Any suggestion?

  • Daniel 22 posts 214 karma points
    May 11, 2017 @ 03:33
    Daniel
    101
        @if(Model.GetPropertyValue<bool>("featuredPost", true))
        {
        <h1 class="post-title">Featured Post</h1>
        }
    

    Managed to make it work by using GetProperty like that, not sure if that's the best approach but it is working as intended right now.

Please Sign in or register to post replies

Write your reply to:

Draft