We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29635
    • 361 Posts
    Hi all. I’m going crazy trying to get this to work. All I want is to have DropMenu display the items with "Show in Menu" unchecked, and hide those with it checked.

    From the code it looks as simple as changing (line 190)
    function filterHidden($var) {
    		return (!$var['hidemenu']==1);
    	}

    to
    function filterHidden($var) {
    		return (!$var['hidemenu']==0);
    	}

    but that outputs the exact same thing! I’m so confused. Even when I remove that whole function, and line 201 too, it still outputs the same thing. The page is non-cacheable, the snippet is in [! !], I’ve refreshed the site. I can’t think of anything else. huh
      Need MODx Ecommerce? Try FoxyCart!
      • 7455
      • 2,204 Posts
      try this:

      remove the ! (! means "if not")
      function filterHidden($var) {
      		return ($var['hidemenu']==1);
      	}
      


      original it will see if hidemenu in $var is not the same as 1 then it shows the items.
      by removing the ! it wil see if hidemenu is the same as one and then show the items.

      good luck
        follow me on twitter: @dimmy01
        • 29635
        • 361 Posts
        Thanks Dimitri. I actually tried that as well and it doesn’t change the behaviour of the snippet at all. ? Unless I’m going crazy...

        No, I just checked again, it displays the exact same thing regardless of 0 or 1, ! or not. (I’m using 0.9.1 now but I had been trying this on 0.9.0 with the same results.)
          Need MODx Ecommerce? Try FoxyCart!
          • 29635
          • 361 Posts
          Ok, this is odd.
          Short Answer: Changing the 1 to a 0 does indeed work, but not if another non-modified DropMenu snippet is called prior to the modded snippet call.

          Long Answer: One of the sites I’m working on has a main nav on the left (vertical), and a subnav across the top (horizontal). Check it out here: 209.126.144.59.

          The left DropMenu is modded to display weblinks correctly (called as DropMenuTMC), the subnav is a regular DropMenu, and on the Course/Member page, I’m calling a third DropMenu (named OrgList) modded to show the "don’t show in menu" items.

          Guess what: Whatever the code that is in the first DropMenu call gets called for all three dropmenus regardless the modified code that’s actually called, and regardless the names of the snippets. If I change the DropMenuTMC (leftnav) to show hidden items, all three menus show hidden. I change it back, all three menus show the non-hidden items.

          Anybody want to confirm this? For the time being, I’m making the 0/1 value that I need changed as a value that’s passed to the snippet, so I can use actually use the same snippet for all three, but this seems like it could be a pretty ugly issue for anybody that needs differently modded dropmenus on the same page.
            Need MODx Ecommerce? Try FoxyCart!
            • 29635
            • 361 Posts
            This doesn’t work either:
            Quote from: The at Jan 06, 2006, 07:38 AM

            For the time being, I’m making the 0/1 value that I need changed as a value that’s passed to the snippet
            So... If you pass a 1 into the first DropMenu call, then a 0 into the second, they both get 1s.

            Just in case you want to see the code:
            $showHidden = (!isset($showHidden)) ? '1' : "$showHidden";
            
            if (!isset ($MakeMap_Defined)) {
            	function filterHidden($var) {
            		return (!$var['hidemenu']==$showHidden);
            	}



            This is driving me nuts. Anybody have any ideas on how to make this work? Thanks!
              Need MODx Ecommerce? Try FoxyCart!
            • Brett, can you file this in the bugtracker so it doesn’t slip by without resolution. That’s really odd... :/
                Ryan Thrash, MODX Co-Founder
                Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                • 29635
                • 361 Posts
                Roger that Ryan. It’s been added, but I think I did a pretty lame job of concisely describing the problem wink

                My PHP is pretty bad, but does it perhaps have something to do with
                global $MakeMap_Defined;

                ? I think my next step is to start renaming functions and see if I stumble on the issue.
                  Need MODx Ecommerce? Try FoxyCart!
                • I think it’s time to probably isolate this into a proper class as was done on the MemberCheck snippet.
                    Ryan Thrash, MODX Co-Founder
                    Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                    • 29635
                    • 361 Posts
                    Thanks for those tips, Ryan. I was reluctant to put it in the bugtracker until I got it working (trying to save you guys the extra work wink ), and I just got it.

                    In case anybody else stumbles on this thread with the same problem, I was able to get around it by changing the names of the following functions:
                    MakeMap
                    MakeMap_Defined
                    filterHidden
                    filterEmpty

                    I just added a 2 to the end of each function and all is well. Now I have one folder with two entirely separate menus.
                      Need MODx Ecommerce? Try FoxyCart!
                    • Thanks Brett!
                        Ryan Thrash, MODX Co-Founder
                        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me