Copied to clipboard

Flag this post as spam?

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


  • Martin 278 posts 662 karma points
    Mar 20, 2018 @ 16:11
    Martin
    0

    Conditional If - Check if property type has string value

    Hi All, I want to check if the property on a page equals a string value. I cant seem to get it to work with the strongly type partial.

    Any help would be grateful.

    Thanks

    Martin

      @foreach (var childPage in home.Children.Where(x => x.IsVisible()))
         {        
            if (childPage.Children.Where(x => x.IsVisible()).Any() && childPage.Where(x => x.GetPropertyValue<string>("navigationDropdown").Equals("secondary")))
    
  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Mar 20, 2018 @ 16:13
    Alex Skrypnyk
    0

    Hi Martin

    What is "secondary"?

    Can you check in /app_data/umbraco.config what is stored in "navigationDropdown" property?

    /Alex

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Mar 21, 2018 @ 07:56
    Michaël Vanbrabandt
    0

    Hi Martin,

    what kind of data type is your navigationDropdown property? I guess it contains a Array of strings and not only one string so the conversion to a string using x.GetPropertyValue<string>("navigationDropdown") fails.

    Hope this helps.

    /Michaël

  • Martin 278 posts 662 karma points
    Mar 21, 2018 @ 08:34
    Martin
    0

    Hi Guys,

    Thanks for replying.

    The property "navigationDropdown" is a textbox data type. It's intended to determine what kind of dropdown style is applied to the child pages.

    I want to check if the string matches "secondary" value.

    Thanks again.

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Mar 22, 2018 @ 18:13
    Alex Skrypnyk
    1

    Hi Martin

    It looks you need something like that:

    @foreach (var childPage in home.Children.Where(x => x.IsVisible() && x.GetPropertyValue<string>("navigationDropdown").Equals("secondary")))
    {
        if (childPage.Children.Where(x => x.IsVisible()).Any())
        {
        }
    }
    

    Child pages that have child pages and "navigationDropdown" property value equals "secondary"?

    Thanks,

    Alex

Please Sign in or register to post replies

Write your reply to:

Draft