Copied to clipboard

Flag this post as spam?

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


  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Feb 24, 2011 @ 17:38
    Ismail Mayat
    0

    List children with select

    Razor gurus,

    I am doing this but could not figure out the linqy way to do it:

                             <umbraco:macro runat="server" language="razor">
                               @using umbraco.MacroEngines                     
                               @{ 
                                   dynamic node = new DynamicNode(1117);
                                   var featured = node.Children;
                               
                               
                               @foreach(var page in featured) {
                                 if(@page.featured){
                                     @page.Id<br/>@page.featured
                                 }
                               }
                               
                             </umbraco:macro>

    I am on home page and page 1117 is of type PortfolioFolder that has bunch of children of type Portfolio that has property alias Featured i wanna list if that is set to true. My dirty code above works but its not very elegant.

    Whats the proper way of doing it.

    Regards

     

    Ismail

     

  • Rick Mather 42 posts 124 karma points
    Feb 24, 2011 @ 17:57
    Rick Mather
    2

    I think this should do it (not tested):

     

    @{
      dynamic node = new umbraco.MacroEngines.DynamicNode(1117);
    }

    @foreach(var page in node.Children.Where("featured")) {
      @page.Id
    }

     

  • Gareth Evans 142 posts 334 karma points c-trib
    Feb 25, 2011 @ 07:29
    Gareth Evans
    0

    @Rick - that looks right.

    Future blog post on umbraco.com will cover .Where

Please Sign in or register to post replies

Write your reply to:

Draft