We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32241
    • 1,495 Posts
    I vote for yes too....

    So will this be implemented in the next release or it will wait until the major release of TP 4?

    I can imagine implementing a breadcrumb, menu, subdomain implementation, language internaionalization, and a lot more, just by having this implementation by default. Is it do able during OnInit event? Fetching the data from database, and store it as an array, make it global/visible, to be accessed externally by snippets/plugins?

    I’m looking forward to it guys. Keep up the good work, and thanks to OpenGeek for taking it as the next project. All the best...

    Sincerely,
    Wendy Novianto
      Wendy Novianto
      [font=Verdana]PT DJAMOER Technology Media
      [font=Verdana]Xituz Media
      • 25663 MODX Staff
      • 12,272 Posts
      Travis IM’d me while I was away with some information regarding a possible way of to do this efficiently:

      Hey. I just saw the posts on the Ultimate Parent and $modx->genes
      Just thought I’d mention that there may be a "nicer" way to do this that wouldn’t cause any overhead when using it, only when saving a page. First, this article: http://www.codeproject.com/database/modhierarchies.asp
      The second is to simply store a lineage field with the records:
      1-2-3-5, for instance
      So sid 1 would have a lineage of 1
      Sid 2 that is a child of 1 would have 1-2
      Sid 3 would have 1-2-3
      Sid would have 1-2-3-5
      When adding a new page, you simply ask the parent page for its lineage and add yourself to the end
      Pulling 1-2% would give you sid 2 (the parent) plus all children
      Sorting by lineage gives you the entire tree in proper order
      Etc
      Facilitates pulling the entire tree, in tree form, with a single query
      Not the most efficient method, but for something like you all are talking about, might be worth considering for its simplicity when inserting and when working with it... Makes it very trivial to find any parent or any child
      Just a thought; I’m sure you all will probably find a better method.

      Let the wheels start turning. smiley
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 8461
        • 205 Posts
        Is there a way of including the parent folder itself as the first list item when using ultimate parent snippet. Ideally I need to have the parent folder for each sub-section listed

        Many thanks
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Quote from: edge at Mar 13, 2006, 07:09 AM

          Is there a way of including the parent folder itself as the first list item when using ultimate parent snippet. Ideally I need to have the parent folder for each sub-section listed

          You could use this snippet’s return value in another snippet to get the parent of the document whose id is returned by this one (use $modx->runSnippet in your second snippet).

          $grandparent = $modx->getParent($modx->runSnippet('GetUltimateParent'));


          I’m not sure what you want to do, though. If you want a list of submenu folders, with only the current document’s submenus showing, you can use a regular DropMenu and use the here class and css to show/hide the submenus.
            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
            • 8461
            • 205 Posts
            Hi Susan

            The only problem with dropmenu is that it will not show the folder (the actual start id page) which in this case I need as its represents the home page for that section. I could have made the first page within that folder the sections home page, but I have another top level menu and that lists each sections folder so that would not have worked

            Many thanks for your help
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              Added an option to stop the search at a certain level.

              // arguments:
              // &id      - the id of the document whose parent you want to find
              // &top     - the top of the search 
              // examples:
              // [[GetUltimateParent?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;
              if($id==$top || $id==0) { return $id; }
              $pid = $modx->getParent($id,1,'id');
              if($pid == $top) { /* echo $id */ return $id; }
              while ($pid != $top) {
                  $id = $pid;
                  $pid = $modx->getParent($id,1,'id');
                  if($pid == $top) { /* echo $id */ return $id; }
              }
              return 0; // if all else fails
              
                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
                • 8461
                • 205 Posts
                Hi Susan,

                Maybe I am being dense today..

                I am using ultimateParent so that I can use a single template in my site. The site has six sections (Folders) and a number of section pages in each folder. I have a sub-menu which lists only the pages for the section I am in (using ultimateparent snippet as my start ID in drop menu) which all works fine.

                I then need to display the folder for each section I am in as this is that sections home page. I cannot hard code any start ID information. Modx needs to display 1. the folder menutitle based on the page I am viewing . 2. Separately Dropmenu will display a list of all pages in that section using UltimateParent (Works great)

                Does that make sense ?
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  Ah, I get it! You need to display the folder’s page content as the subsection’s homepage! I was totally focused on the menu itself! If a weblink won’t work because you need the id to be a variable, make a document that uses a snippet or a TV to redirect to the proper folder/document (such as the parent of the ultimate parent as I suggested below).
                    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
                    • 8461
                    • 205 Posts
                    Hi

                    Its OK I have got it solved with following code

                    <a href="[~[[UltimateParent]]~]">[!getdoc? &id=`[[UltimateParent]] &field=`menutitle`!]</a>
                      • 6726
                      • 7,075 Posts
                      Waow that’s a pretty nifty trick, thanks for sharing !
                        .: COO - Commerce Guys - Community Driven Innovation :.


                        MODx est l&#39;outil id