We're evolving to serve you better! This current forum has transitioned to read-only mode. For new discussions, support, and engagement, we've moved to GitHub Discussions.

Count the entries of a menu

  • #10184
    Avatar photo[anonymous]


    I would like to find out how many entries a navigation has (only the main menu – no sub-entries). Something like:


    Is this possible?

    Thank you very much!

    Avatar photo[anonymous]

    I don’t know if it’s the best solution, but that’s how I did it:


    let themeHelpers = {
        // Counts all elements of an array
        countArray: function(arrayContent) {
            if (arrayContent.constructor === Array) {
                return arrayContent.length;
            } else {
                return 0;
    module.exports = themeHelpers;

    in the template:

    {{#checkIf (countArray menus.mainMenu.items) '==' 4}}
    show something...

    Works for me…