We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7455
    • 2,204 Posts
    I have the folloing menu structure:

    language1
                mainmenuoflangage1
                                              submenuofmainmenuoflaguage1
                                                                    submenuofsubmenuofmainmenuoflanguage1
    language2
                mainmenuoflangage2
                                              submenuofmainmenuoflaguage2
                                                                    submenuofsubmenuofmainmenuoflanguage2
    language3
                mainmenuoflangage3
                                              submenuofmainmenuoflaguage3
                                                                    submenuofsubmenuofmainmenuoflanguage3

    I do not use a menu for the languages they are only folders to devide the languages. (I use a chunk to show clickable flags)
    my main menu is always the "mainmenuoflangage" menu
    now I use listglobal with [[UltimateParent]] to set the right language (to get the right "mainmenuoflangage")
    now I use dropmenu to show the submenu’s , if I only use one language this could easaly be done with the use of [[UltimateParent]] but now I need it not to be the ultimate parent but the child of the ultimate parent, is there a option to do that?

    Hope somone can help me
    DImmy
      follow me on twitter: @dimmy01
      • 7455
      • 2,204 Posts
      ok made my own snippet based on Listsections by Jared
      SectionRoots
      works great.
      Thanks for all the help
        follow me on twitter: @dimmy01
        • 21056
        • 327 Posts
        I had a problem with this snippet, where if you specify a top which is not in the ancestry of the id, it gets stuck in an infinite loop which isn’t good for the server!

        I’ve modified the snippet so it can take an extra parameter (topNotFound) for the ID to return if the page specified is not found before it reaches the root. If this isn’t specified, and the top is not found, it just returns the ID of the current document.

        What’s the best way of requesting this is added to the distribution?

        <?php
        // UltimateParent - snippet for MODx 0.9x
        // v1.3
        // Travels up the document tree from the current document
        // to return the "ultimate" parent
        // March 2006 - [email protected]
        // Bug fix Sept 17, 2006 - Jason Coward <[email protected]>
        // Bug fix Dec 7, 2006 - Nick
        // Released to the Public Domain, use as you like
        // arguments:
        // &id      - the id of the document whose parent you want to find
        // &top     - the top of the search 
        // &topNotFound - the id to return if the top specified is not found (defaults to current ID)
        // examples:
        // [[UltimateParent? &id=`45` &top=`6`]]
        // will find the first parent of document #45 under document #6
        // if id == 0 or top == id, will return id.
        // you can use this as the startDoc for DropMenu to create specific submenus.
        
        $top = isset($top)?$top:0;
        $id = isset($id)?$id:$modx->documentIdentifier;
        $topNotFound = isset($topNotFound )?$topNotFound :$id;
        if($id==$top || $id==0) { return $id; }
        $pid = $modx->getParent($id,1,'id');
        if($pid['id'] == $top) { return $id; }
        while ($pid['id'] != $top ) {
            $id = $pid['id'];
            $pid = $modx->getParent($id,1,'id');
            if($pid['id'] == $top) { return $id; }
            if($pid['id'] == 0) { return $topNotFound ; }
        }
        return 0; // if all else fails
        ?>
          Author: ManagerManager plugin - customise your ModX manager interface

          Rckt - web development, Sheffield, UK
          • 22303 MODX Staff
          • 10,725 Posts
          @ncrossland: can you take a look at UltimateParent 2.0 and see if this same issue exists, and if so, I’d like to fix it there and release this with 0.9.5.1 in the next few days...
            • 21056
            • 327 Posts
            Quote from: OpenGeek at Dec 08, 2006, 09:41 PM

            @ncrossland: can you take a look at UltimateParent 2.0 and see if this same issue exists, and if so, I’d like to fix it there and release this with 0.9.5.1 in the next few days...
            Just tested it and the issue doesn’t happen in UltimateParent 2.0 grin

            If you put in a top ID which isn’t in the ancestry of the page, it seems to return the root level rather than looping infinitely, as 1.0 did!
              Author: ManagerManager plugin - customise your ModX manager interface

              Rckt - web development, Sheffield, UK
              • 33372
              • 1,611 Posts
              I had trouble with this snippet because some of my subfolders were unpublished. I couldn’t get it to work for me at all using the getParent function so I had to rewrite the whole thing using a regular dbQuery. It seems as if there ought to be a way to use getParent (and getDocument) irrespective of its published state (e.g., 0=unpublished, 1=published, and 2=either)... there isn’t, though, is there?
                "Things are not what they appear to be; nor are they otherwise." - Buddha

                "Well, gee, Buddha - that wasn&#39;t very helpful..." - ZAP

                Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
                • 7923
                • 4,213 Posts
                You should really get the UltimateParent 2 snippet from the forums that doesn’t use queries at all..


                  "He can have a lollipop any time he wants to. That's what it means to be a programmer."
                  • 33372
                  • 1,611 Posts
                  I thought that version 1.2 was the latest, but now that I searched the forums I found the new beta version you mention (thanks!).

                  However it wouldn’t have helped me in this case because this site is running 0.9.2.x and they don’t want to upgrade yet (I expect Ryan will scold me for this...).

                  Does what I’m suggesting regarding the getDocument and getParent functions make sense in any case?
                    "Things are not what they appear to be; nor are they otherwise." - Buddha

                    "Well, gee, Buddha - that wasn&#39;t very helpful..." - ZAP

                    Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
                    • 25663 MODX Staff
                    • 12,272 Posts
                    Consider yourself scolded. tongue
                      Ryan Thrash, MODX Co-Founder
                      Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                      • 22303 MODX Staff
                      • 10,725 Posts
                      Quote from: ZAP at Jan 28, 2007, 06:07 PM

                      Does what I’m suggesting regarding the getDocument and getParent functions make sense in any case?
                      Although I am deprecating both of those functions in 0.9.7, they would be good improvements to them for a patch release of 0.9.5.x and their remaining lifetime before 1.0. If you’ll enter a request for this functionality in the bug tracker, I’ll make sure it gets into 0.9.7 and ported back, possibly for 0.9.5.1.