Copied to clipboard

Flag this post as spam?

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


  • Amir Khan 1287 posts 2744 karma points
    Mar 11, 2013 @ 19:39
    Amir Khan
    0

    Error when checking for NodeTypeAlias in If statement

    So i'm getting an error "umbraco.MacroEngines.DynamicNodeList does not contain a definition for "NodeTypeAlias""

    What is the correct way to check if a node is of a certain document type?

    if (page.Children.Where("Visible").Count() > 0 || page.Children.NodeTypeAlias != "LocationPageMC")
    {
    <li class="@page.IsLast("last")">
    @RenderPageAnchorWithDrop(page)
    </li>
    } else {
    <li class="@page.IsLast("last")">
    @RenderPageAnchor(page)
    </li>
    }
  • Fuji Kusaka 2203 posts 4220 karma points
    Mar 11, 2013 @ 19:56
    Fuji Kusaka
    0

    Hi Amir,

    You can do this

    if(page.Children.Where("NodeTypeAlias == \"LocationPageMc\"").Count()>0){}
  • Amir Khan 1287 posts 2744 karma points
    Mar 11, 2013 @ 20:01
    Amir Khan
    0

    Hi Fuji, thanks for your reply, this returns nothing it seems? It hides the LocationPageMc pages, but also every other page...What I'm trying to achieve is "if page.Children is visible and is NOT LocationPageMC > RenderPageAnchorWithDrop()"

     

  • gary 385 posts 916 karma points
    Mar 11, 2013 @ 20:34
    gary
    1

    Hi Amir

    You should be able to add two Where statements, have used this in the past, but it may depend on the Umbraco Version.

    page.Children.Where("Visible").Where("NodeTypeAlias!= \"LocationPageMC\"")

    If not post back with Umbraco version you are using and if MVC or webforms, and info on how you create var page, then it may be easier to assist you.

    Regards G

     

  • Fuji Kusaka 2203 posts 4220 karma points
    Mar 11, 2013 @ 20:35
    Fuji Kusaka
    100

    Not sure then it should be

    NodeTypeAlias !=\"LocationPageMc\""
  • Amir Khan 1287 posts 2744 karma points
    Mar 11, 2013 @ 21:00
    Amir Khan
    0

    Gary, Fuji, thanks! The below worked great.

    .Where("NodeTypeAlias!= \"LocationPageMC\"")
Please Sign in or register to post replies

Write your reply to:

Draft