Copied to clipboard

Flag this post as spam?

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


  • Ben 108 posts 374 karma points
    Jan 30, 2014 @ 21:47
    Ben
    0

    Filter Collection of Pages By Custom Property

    I need some help filtering on the custom property of a page.  I have seen a few posts where others are doing it, but it doesn't work for me.  Here is the code I am trying to get to work:

    @helper MainNavAd(int menuItemID){
      var topNavAdsFolder = Library.NodeById(1268);
    
      <div class="subnav_content">
        this is my subnav content from the helper method: @menuItemID - 
    
        @*topNavPage is a Content Picker*@
        @topNavAdsFolder.Children.Where("topNavPage == @0", menuItemID).Count()
      </div>
    }

    This gives me the output of:
    this is my subnav content from the helper method: 1059 - 0

    But if i adjust the code to this:

    @helper MainNavAd(int menuItemID){
      var topNavAdsFolder = Library.NodeById(1268);
    
      <div class="subnav_content">
        this is my subnav content from the helper method: @menuItemID - 
    
        @*topNavPage is a Content Picker*@
        @topNavAdsFolder.Children.First().GetPropertyValue("topNavPage")
      </div>
    }

    I get the follow:
    this is my subnav content from the helper method: 1059 - 1059

    So I feel like I am almost there.  Just can't figure out how to do the filtering without looping through all the children and using GetPropertyValue to compare the custom property.  

    Any help would be appreciated.

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Jan 31, 2014 @ 09:38
    Jeavon Leopold
    100

    Hi Ben,

    I think you just have a type comparison issue, try this:

    @helper MainNavAd(int menuItemID){
      var topNavAdsFolder = Library.NodeById(1268);
    
      <div class="subnav_content">
        this is my subnav content from the helper method: @menuItemID - 
    
        @*topNavPage is a Content Picker*@
        @topNavAdsFolder.Children.Where("topNavPage == @0", menuItemID.ToString()).Count()
      </div>
    }
    

    Jeavon

  • Ben 108 posts 374 karma points
    Jan 31, 2014 @ 14:01
    Ben
    0

    That was it!  Thank you so much.  I knew I was missing something.

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Jan 31, 2014 @ 14:13
    Jeavon Leopold
    0

    Awesome!

Please Sign in or register to post replies

Write your reply to:

Draft