We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 18654
    • 191 Posts
    I’m having trouble figuring out how the "Show Sorting Options" icon in the "Web Resources" area is supposed to work. I’ve tried right-clicking and left-clicking (Firefox and Chrome) but nothing happens. How is this button supposed to work?

    -matt
      God does not save those who are only imaginary sinners. Be a sinner, and let your sins be strong, but let your trust in Christ be stronger, and rejoice in Christ who is the victor over sin, death, and the world.
    • Quote from: mattcdavis1 at Sep 12, 2009, 10:39 PM

      I’m having trouble figuring out how the "Show Sorting Options" icon in the "Web Resources" area is supposed to work. I’ve tried right-clicking and left-clicking (Firefox and Chrome) but nothing happens. How is this button supposed to work?

      -matt
      You just click it (left click) and it displays the sorting options. Seems to be working fine here...
        • 18654
        • 191 Posts
        hmmm... I tried restarting my computer and then with Chrome, IE8 and FF3 3.5.3 but nothing. All the other buttons work fine except for that one. I’ll do some more troubleshooting and see if I can figure out what’s going on.

        Thanks, matt
          God does not save those who are only imaginary sinners. Be a sinner, and let your sins be strong, but let your trust in Christ be stronger, and rejoice in Christ who is the victor over sin, death, and the world.
          • 28215
          • 4,149 Posts
          Are you using beta3 or SVN?

          This was fixed in post-beta3 commit of SVN.
            shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
            • 18654
            • 191 Posts
            beta3 not svn - I guess that explains it then. Thanks!

            In the meantime, I was trying to figure out the best way to sort an array of objects returned by getMany to create and alphabetize a menu.

            Basically, I want to get all children of a document by using getMany and then sort the objects by ’pagetitle’ property. Here’s what I’ve got:

            $int_pageId = $modx->resource->get(’id’); //gets id of current page
            $obj_currentPage = $modx->getObject(’modResource’,$int_pageId); //get’s current page as an object
            $children = $obj_currentPage->getMany(’Children’); //gets object array of current object’s children for menu.
            //now I just need to figure out how to sort the array by the pagetitle property of each object and then I can output ’link’ and ’pagetitle’ properites using a foreach loop with parseChunk
              God does not save those who are only imaginary sinners. Be a sinner, and let your sins be strong, but let your trust in Christ be stronger, and rejoice in Christ who is the victor over sin, death, and the world.
              • 28215
              • 4,149 Posts
              Quote from: mattcdavis1 at Sep 13, 2009, 09:54 PM

              Basically, I want to get all children of a document by using getMany and then sort the objects by ’pagetitle’ property. Here’s what I’ve got:

              $int_pageId = $modx->resource->get(’id’); //gets id of current page
              $obj_currentPage = $modx->getObject(’modResource’,$int_pageId); //get’s current page as an object
              $children = $obj_currentPage->getMany(’Children’); //gets object array of current object’s children for menu.
              //now I just need to figure out how to sort the array and then I can output ’link’ and ’pagetitle’ properites using a foreach loop with parseChunk

              Try this:

              $c = $modx->newQuery('modResource');
              $c->where(array(
                 'parent' => $modx->resource->get('id'),
              ));
              $c->sortby('pagetitle','ASC');
              $children = $modx->resource->getMany('Children',$c);
              

              By the way - you don’t need to getObject the current resource as an object; $modx->resource is exactly that.
                shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
                • 18654
                • 191 Posts
                That worked perfect - Thanks!
                  God does not save those who are only imaginary sinners. Be a sinner, and let your sins be strong, but let your trust in Christ be stronger, and rejoice in Christ who is the victor over sin, death, and the world.
                  • 28215
                  • 4,149 Posts
                  No problem; by the way, ongoing documentation on xPDO, the db layer for Revolution, can be found here:

                  http://svn.modxcms.com/docs/display/XPDO10/Home

                  and you can find API docs here:

                  http://api.modxcms.com/
                    shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
                    • 18654
                    • 191 Posts
                    I’ve been looking at the docs for the past couple hours trying to understand the last line of code. I think I understand the process up until then:

                    1. Create a new query object with criteria "modResource" which returns an array of all modResource objects.
                    2. Filter query object-array using "where" method so that only items meeting criteria remain in object array.
                    3. Sort query object-array using "sortby" method.
                    4. Here’s where I’m having trouble:

                    $children = $modx->resource->getMany(’Children’,$c);

                    I think I understand that what we’re saying here is let’s call the "getMany" method of the current object with the criteria of "Children" - but what’s throwing me off is the second parameter. I don’t understand how that fits into things. I was reading Bob’s guides, for example, and he writes "Remember that getOne() and getMany() always take a single argument" which obviously is not the case here.

                    I can see in the API docs that: "void getMany ( $class, [ $criteria = null], [ $cacheFlag = false])"

                    From this I understand that there are two additional, optional parameters, but I can’t seem to find any more info on how these parameters (particularly the second one which is what is used here) fit into the equation. Any help would be appreciated. Perhaps there is some additional info on this somewhere and I’m just not finding it?

                    Thanks,

                    -matt
                      God does not save those who are only imaginary sinners. Be a sinner, and let your sins be strong, but let your trust in Christ be stronger, and rejoice in Christ who is the victor over sin, death, and the world.
                      • 3749
                      • 24,544 Posts
                      The getOne() and getMany() methods definitely take more than one argument. I’m not sure if that’s new or if I just screwed up when I wrote that.

                      At any rate, here’s the deal as I understand it. The first argument is the class name of the object you want. In your case, ’Children’ which is an alias (kind of a pseudo-class).

                      It’s the optional *second* argument that contains the criteria ($c in this case), which is a query object, built over several lines, that ends up being decoded as a query string when passed to getOne() or getMany().

                      Hope this makes sense. smiley

                      BTW: I tested Shaun’s code and it definitely works. If you add this to it, it should display the children (sorted):

                      foreach($children as $child) {
                      
                         $output .= $child->get('pagetitle') . '<br />';
                      }
                      return $output;
                        Did I help you? Buy me a beer
                        Get my Book: MODX:The Official Guide
                        MODX info for everyone: http://bobsguides.com/modx.html
                        My MODX Extras
                        Bob's Guides is now hosted at A2 MODX Hosting