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.
    The site I’m doing right now has a main vertical menu on the left, and a submenu along the top (http://access.themancan.com). I’m using DropMenu for both menus. The first menu item (About) is an empty folder that contains 5 content items.

    The DropMenu snippet allows for empty folders (with template=blank) to be displayed as non-links. My question is: How can I make it display empty folders (with template=blank) be links to the first child element?

    I’ve spent a few hours trying to hack the DropMenu snippet but haven’t had any luck. Right now I have it set up with a meta refresh TV, which is sloppy and slower, but it does maintain the "current page" indication in both menus. (I’ve tried making those empty parent folders weblinks to the appropriate child, but weblinks don’t do well at all in the DropMenu snippet. I’ve tried .htaccess redirects also, but those don’t work either. I can’t think of anything else that would maintain the current page indication.)

    Thanks so much for any help!
    -Brett
      Need MODx Ecommerce? Try FoxyCart!
      • 26435
      • 1,193 Posts
      Looks like you found a workaround. Are you using a <META HTTP-EQUIV="Refresh" CONTENT="0; URL=example_page.html">?

      -sD-
      scotty Delicious
        Husband, Father, Brother, Son, Programmer, Atheist, Nurse, Friend, Lover, Fighter.
        All of the above... in no specific order.


        I send pointless little messages
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        Quote from: The at Nov 12, 2005, 10:24 PM

        (I’ve tried making those empty parent folders weblinks to the appropriate child, but weblinks don’t do well at all in the DropMenu snippet.

        Odd, I’m using weblinks extensively with DropMenu in multilanguage sites, where the "parent" folder is the container for all of the language content for that language. One DropMenu makes a single-level "languages" menu out of the root folder, and the other makes the main menu out of the folders within the given "root" language folder, so I use a weblink within the second level to the "root" langauge folder, which doubles as the langauge home page, so that there is a "Home" link as well; they work just fine. In fact, I even have one template where I have an empty folder full of weblinks for a "links" menu, and use DropMenu for it with no trouble.
          Studying MODX in the desert - http://sottwell.com
          Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
          Join the Slack Community - http://modx.org
          • 29635
          • 361 Posts
          Thanks so much Susan and Scotty for the responses.
          I am indeed using a meta refresh, and though it works, it’s kind of hackish.

          Susan, whenever I try to use a weblink it seems to default thinking it’s an empty category and will not apply a link to it. I’m using
          [!DropMenu? &menuName=navMain &topnavClass=navMain &levelLimit=1 &useCategoryFolders=false !]

          and it’s still looking like this:


          Based on the DropMenu instructions (within the snippet) it seems like setting the useCategoryFolders to false should work, but it doesn’t seem to do anything with a weblink. It seems like the problem may be that weblinks cannot have a template applied to them, and the DropMenu looks for the template to be "blank".

          Susan, if I understand you correctly, you’re using weblinks to point back to the parent folder, yes? Are you able to get the current page indication on a weblink? I’ve tried that technique on the "Resources" link but it doesn’t give indication.
          =================================================
          I figured it out. I changed the line (around 218):
          $itsEmpty = ($isFolder && ($child[’template’] == ’0’));
          to
          $itsEmpty = ($isFolder && ($child[’template’] == ’10’));
          and it displays a weblink as a link. "You are here" works beautifully as well. (I’m sure the ’10’ could be anything else other than 0.)

          I think the problem is that somehow it’s not acknowledging the useCategoryFolders on a weblink. I even hardcoded it in the snippet to false and it still didn’t change anything. Any ideas there?

          Thanks so much for your patience and help! I really appreciate your expertise and time. -Brett
            Need MODx Ecommerce? Try FoxyCart!
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            No, I haven’t gotten the "here" to work on it; I haven’t really worried about it since the site involved only has one level for each langauge, and the multilanguage part was "interesting" enough. I have never used that useCategoryFolder argument. Looks like that part of DropMenu needs a bit of tweaking so it doesn’t regard a weblink as an empty document.
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              Quote from: The at Nov 13, 2005, 01:34 AM

              ...the line (around 218):
              $itsEmpty = ($isFolder && ($child[’template’] == ’0’));

              Why can’t that condition be ($child[’content’] == "")?

              Seems to me basing a condition on something specific that the user has to do when creating his documents is kind of iffy, but if needed I would rather have to specifically put something in the document’s description, such as "empty folder", then the condition could check for that. That way you know for sure it’s not going to be getting tangled up in other things, like the template issue with weblinks.

              $itsEmpty = ($isFolder && ($child[’description’] == ’empty folder’));

              (and, with your solution, what happens when you have ten or more templates, and want to use the 11th template? All of your folders will show as empty!)

                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org
                • 22303 MODX Staff
                • 10,725 Posts
                An alternative approach to this would be to simply use a snippet in the content of the folder document that finds and redirects itself to the first child. Here is one I wrote for this purpose quite some time ago for Eto, updated for MODx...

                if (!isset($id)) $id=$modx->documentIdentifier;
                $children=$modx->getActiveChildren($id,'menuindex','ASC');
                if (!$children===false)
                {
                $firstChild = $children[0];
                $firstChildUrl = $modx->makeUrl($firstChild['id'], $firstChild['alias']);
                }
                else
                {
                $doc = $modx->getDocument($modx->config['site_start']);
                $firstChildUrl = $modx->makeUrl($doc['id'],$doc['alias']);
                }
                return $modx->sendRedirect($firstChildUrl);
                
                  • 26435
                  • 1,193 Posts
                  This topic piqued my interest becuase I have three folders on my site (Lyrics, Templates, and Tutorials) that "hold" other documents, but contain no content themselves. My solution was to just put some cheezy generic description of the folders sub pages as its content, but I really like the idea of being able to have a document immediately loaden on selecting a blank folder. Jason, your suggestion seems to be pretty sensible and it appears that it doesn’t take much to configure. Thanks for porting and sharing that snippet from eto.

                  -sD-
                  scotty Delicious
                    Husband, Father, Brother, Son, Programmer, Atheist, Nurse, Friend, Lover, Fighter.
                    All of the above... in no specific order.


                    I send pointless little messages
                    • 22303 MODX Staff
                    • 10,725 Posts
                    No problem...and actually to make it more efficient (by reducing database calls) in the current version of MODx, I’d remove the getDocument. This was in the code because in Etomite, the makeUrl function required the alias to be specified for a document in order for it to render properly with friendly URL’s. In MODx 0.9.0+, you do not need to specify the alias for the function to return the proper alias, so we can actually reduce this code down to...

                    if (!isset($id)) $id=$modx->documentIdentifier;
                    $children=$modx->getActiveChildren($id,'menuindex','ASC');
                    if (!$children===false)
                    {
                    $firstChild = $children[0];
                    $firstChildUrl = $modx->makeUrl($firstChild['id']);
                    }
                    else
                    {
                    $firstChildUrl = $modx->makeUrl($modx->config['site_start']);
                    }
                    return $modx->sendRedirect($firstChildUrl);


                    I just called it FirstChild, and you can supply an optional `id` snippet parameter to specify a different folder from which to retrieve the first child. You could also easily modify the default set in the else block to be something other than the site_start page.
                      • 26435
                      • 1,193 Posts
                      Tre cool man! Thank you so much for sharing!

                      -sD-
                      scotty Delicious
                        Husband, Father, Brother, Son, Programmer, Atheist, Nurse, Friend, Lover, Fighter.
                        All of the above... in no specific order.


                        I send pointless little messages