We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33982 ☆ A M B ☆
    • 476 Posts
    I've got a site I'm building with a drop down menu. One of the drop down menus has over 100 Resources under the parent which is a bit too long. How would I go about limiting the amount of children that are displayed on the drop down menus? I suppose I could get hacky and put in getResources in the innerTpl like so:

    <ul>
    [[getResources? &parents=`[[*id]]` &tpl=`dropdown_list_nav` &limit=`10` &level=`1`]]
    </ul>
    


    Is is there a better way to do this in Wayfinder?
      Precision Web Development ... SmashStack.com
      • 19369
      • 1,098 Posts
      Maybe with the "&limit" parameter?
      http://rtfm.modx.com/display/ADDON/Wayfinder
        • 33982 ☆ A M B ☆
        • 476 Posts
        Quote from: microcipcip at Jul 18, 2012, 05:59 PM
        Maybe with the "&limit" parameter?
        http://rtfm.modx.com/display/ADDON/Wayfinder

        Thanks for the response. I tried the &limit parameter and it really didn't seem to work in the way I needed it to. Either I'm misunderstanding how to use or just don't understand it all. I looked for documentation on using it, but haven't been able to find it.
          Precision Web Development ... SmashStack.com
          • 19369
          • 1,098 Posts
          I have never used the &limit parameter so I am not sure why it does not work. I guess you may place getResources inside a Wayfinder template, but you have to be super-extra-careful about the performance.
            • 9207 ☆ A M B ☆
            • 2,475 Posts
            &limit should limit the total number of rows returned, just as it would in a SQL statement. It doesn't do anything "intelligent" like limit the number of children. If you've got just one parent that went octo-mom on you, the best way to approach it might be to use separate getResources call just for that one node. If a static menu is possible, that might be an option too -- it'd certainly be faster, performance-wise.
              • 33982 ☆ A M B ☆
              • 476 Posts
              Thanks Everett for that info...definitely helps me understand it more. I went with jQuery as the solution:

              <script type="text/javascript">
              $(document).ready(function(){
              	var count=0;
              	$('ul.header_nav').children('li').eq(2).find('ul').children('li').each(function(){
              		count++;
              		if(count>6){
              		$(this).addClass('hidden');
              		}
              	});
              });
              </script>
              


              Octomom...nice wink
                Precision Web Development ... SmashStack.com
                • 9207 ☆ A M B ☆
                • 2,475 Posts
                jQuery...mmm.... well, that works, but I cringed a bit reading that: it's inefficient to do it that way... it's a bit like an ostrich poking his head into the sand to "escape" danger.

                I was thinking something like this for your menu Chunk:

                <li>Parent 1
                    [[getResources? &parents=`1` ... ]]
                </li>
                <li>Parent 2
                    [[getResources? &parents=`2` ... ]]
                </li>
                <li>Parent 3
                    [[getResources? &parents=`3` ... &limit=`10`]]
                </li>
                


                Your parent resources probably don't change all that often, so it'd be fine to hard-code them, and then you could tweak the limit parameter for each as needed. Note that this example could be cached, and that would be nice for speed. It's pretty much the same scenario for Wayfinder.
                  • 19369
                  • 1,098 Posts
                  What about an if statement inside &rowTpl, and output something else depending on the id:
                  [[If? 
                       &subject=`[[+wf.id]]` 
                       &operator=`=` 
                       &operand=`5` 
                       &then=`[[Wayfinder? &limit=`5`]]` 
                       &else=`[[+wf.wrapper]]`
                  ]]
                    • 33982 ☆ A M B ☆
                    • 476 Posts
                    Quote from: microcipcip at Jul 19, 2012, 10:16 PM
                    What about an if statement inside &rowTpl, and output something else depending on the id:
                    [[If? 
                         &subject=`[[+wf.id]]` 
                         &operator=`=` 
                         &operand=`5` 
                         &then=`[[Wayfinder? &limit=`5`]]` 
                         &else=`[[+wf.wrapper]]`
                    ]]

                    That's actually a fascinating approach. I'll have to give that one a try. @Everettg_99, I guess I was hoping to avoid hard coding the navigation as it always causes problems down the road when the client wants to start shifting things around. I was also worried about putting getResources inside a Wayfinder call for performance issues, but you bring up a good point on caching.

                    Thanks for the feedback on all this...will try these options out.
                      Precision Web Development ... SmashStack.com
                      • 19369
                      • 1,098 Posts
                      Ok, let me know if that works.

                      Btw, you should use +wf.docid, not +wf.id. I always confuse them.