We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37317
    • 77 Posts
    Hi,

    I am quite new at modx, so bare with me smiley

    I have created a snippet which I am outputting my menu. My menu is resource pages that are not hidemenu variable.
    What is the syntax of looping through all resource pages that are not hidden from menu? I need to grab only the pagetitle and pageid.
    I already know how to grab the current page id.

    Thanks
      • 22303 MODX Staff
      • 10,725 Posts
      This is what getResources is used for. You might look at the source code for it to get some ideas if you prefer to roll your own Snippet.
        • 37317
        • 77 Posts
        thanks for the help opengeek.

        I have done the following.

        I put the following code call in my template:
        [[!getResources? &parents=`0` &depth=`0` &sortby=`menuindex` &sortdir=`asc` &tpl=`MenuItem`]]


        then i created a chunk with the following code:
        <li><a href="?id=[[~[[+id]]]]">[[+pagetitle]]</a></li>


        I can't seem to find how to only show "hidemenu" = 0 pages. How can i add that to the call?

        Also i need an "if statement" within the chunk that checks whether the current page id is the same as one of the looped one and if so, then add a different class name (aka. active).

        help?
          • 37317
          • 77 Posts
          anyone?
            • 22303 MODX Staff
            • 10,725 Posts
            Try this as your chunk:

            <li[[+id:eq=`[[*id]]`:then=` class="active"`:else=``]]><a href="[[~[[+id]]]]">[[+pagetitle]]</a></li>


            And getResources does not include Resources that are marked hidden in menu by default unless you set the property &showHidden=`1`.
              • 37317
              • 77 Posts
              Thank you!!!
              that helped and did the trick smiley