We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29635
    • 361 Posts
    Quote from: sottwell at Nov 13, 2005, 02:00 AM

    $itsEmpty = ($isFolder && ($child[’description’] == ’empty folder’));
    Thanks Susan, that works beautifully. Mine was a quick hack that worked for my immediate needs, but your solution is quite elegant and still maintains the functionality if desired. I tried it with $child[’content’]==’’ but it still doesn’t seem to respect the useCategoryFolders, so no go.

    Thanks again!
      Need MODx Ecommerce? Try FoxyCart!
      • 29635
      • 361 Posts
      I just got around to using that snippet and it works like a charm. Thanks a ton for creating it. Very very handy.

      Just gotta put it in the [! !] brackets, not the [[ ]].
        Need MODx Ecommerce? Try FoxyCart!
        • 3758
        • 17 Posts
        Hi All.

        I’m also trying to get this "thing" working, but still without success.
        I’ve read this thread again and again and I think reading it again will confuse me more and more! huh


        Please, can anyone explain the solution for a Dummy like me? grin

        Thanks for any help!
        Boris
          • 29635
          • 361 Posts
          Hi Boris,
          The best way to do this is just to have a regular document as the parent, and put Jason’s snippet in the content. That’s it!

          I’ve taken to calling Jason’s snippet FirstChildRedirect, and have attached a very slightly modified version of the snippet to this post. This method seems to be better than using links (and hacking the DropMenu snippet) in my experience. (After having done both a few times, it’s just easier to use the snippet with regular documents, rather than weblinks. Documents are more felxible, can have TVs attached so you can set up nice @INHERIT stuff, etc.)

          Just make sure you call the snippet uncached, so [!FirstChildRedirect!] rather than [[FirstChildRedirect]].

          Best,
          Brett
            Need MODx Ecommerce? Try FoxyCart!
            • 3758
            • 17 Posts
            Brett

            thank you very much! laugh
            Now I got it! It is just a little confuse reading two different solutions at once.

            Thanks again!
            Boris
              • 11413
              • 203 Posts
              That snippet really helped me!! But how to make it impossible for the other users (I’m the admin) to modify that document then?? I tried to put the document in a dummy group, but when I logged out from the manager and tried to load that page, I got all my TVs, snippets and chunks printed on a white screen, without any parsing and formatting...

              I thought about using a TV with a true/false option to set up the redirection... I think it should be added to the core and as a directory option that you just have to check smiley

              bye

              Blaise
                Blaise Bernier

                www.medialdesign.com - Solutions for small business, hosting, design and more!
                • 21136
                • 103 Posts
                Quote from: OpenGeek at Nov 13, 2005, 02:14 PM

                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.

                This code is working great - but I need it to look for the alias=’index’ within the folder - or whatever alias I need it to point to. Can someone please alter this to look for the alias=’index’

                Regards smiley

                Ken