Copied to clipboard

Flag this post as spam?

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


  • Takashi Koyama 15 posts 56 karma points
    Feb 20, 2015 @ 17:34
    Takashi Koyama
    0

    How to use count() function.

    Hi, I have the following code.

    @{

    var selection = CurrentPage.Site().Children.Where("Visible");

    }

     

    I want to do something like

    var numPage = count(selection);

    But umbraco does not like this.  What else do I need for the above?

     

     

  • Jan Skovgaard 11258 posts 23500 karma points MVP 7x admin c-trib
    Feb 20, 2015 @ 17:37
    Jan Skovgaard
    100

    Hi Takashi

    You should be able to simply do

    @{ var selection = CurrentPage.Site().Children.Where("Visible"); selection.Count(); }

    Does this work?

    /Jan

  • Takashi Koyama 15 posts 56 karma points
    Feb 20, 2015 @ 17:40
    Takashi Koyama
    0

    That works great!  Thanks Jan.

  • Jan Skovgaard 11258 posts 23500 karma points MVP 7x admin c-trib
    Feb 20, 2015 @ 17:48
    Jan Skovgaard
    0

    Hi Takashi

    You're welcome - You might benefit from having this cheatsheet open when you do razor in Umbraco btw :) https://our.umbraco.org/projects/developer-tools/umbraco-v6-mvc-razor-cheatsheets

    Happy coding.

    /Jan

  • Takashi Koyama 15 posts 56 karma points
    Feb 20, 2015 @ 18:00
    Takashi Koyama
    0

    Thanks, Jan.  That's a great cheat sheet!

  • 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