Copied to clipboard

Flag this post as spam?

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


  • pronto 61 posts 172 karma points
    Sep 24, 2013 @ 17:42
    pronto
    0

    Display multiple nodes based on doctype with Where clause

    Hi everyone,

    I'm trying to display certain doctypes from my node tree using the foreach where clause and I'm having difficulty finding the correct syntax. For instance, if I have 10 different doctypes in my site and I want to display every page that has the doctype 'Page1' and 'Page2', what is the best way to achive this? Currently using Umbraco 4.11.10. Here's something I've tried but I recieve the error 'Can only unbox from an object or interface type to a value type':

    @{
      
    var r = Model.NodeById(1000);
    
    foreach(var x in r.Children.Where("NodeTypeAlias == Page1 || NodeTypeAlias == Page2")){
    <p>@x.Name</p> } }


    Cheers,
    pronto

  • Jeavon Leopold 3008 posts 13221 karma points MVP 7x admin c-trib
    Sep 24, 2013 @ 17:56
    Jeavon Leopold
    1

    Hi Pronto,

    You might give this a try:

    @{  
        var r = Model.NodeById(1000);    
        foreach(var x in r.Children.Where("NodeTypeAlias == @0 || NodeTypeAlias == @1", "Page1", "Page2")){
            <p>@x.Name</p>
        }
    }
    

    Further info here

    Jeavon

  • pronto 61 posts 172 karma points
    Sep 24, 2013 @ 18:33
    pronto
    100

    Hi Jeavon,

    That's perfect, thank you!

    Cheers,
    pronto 

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies