We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3749
    • 24,544 Posts
    Is there any way to control the order in which elements are installed?

    The install order determines their order in the tree. Dragging them doesn’t seem to work and, even if it did, it would be nice to control how they looked initially. With the new pseudo-ids, they seem to be ordered somewhat randomly. Every time I change something in the build script, it seems to change the order in which they’re installed even though I’ve always created them in the same order in the build script.

    I think they’re installed in the order they appear in the package build directory which depends on the file names. Would it be possible to prepend a number to the file names that was incremented as they are added to the package? Or is there some other way to control the order?

    I’m not sure, but it seems there might be consequences of the install order with related objects, categories, and when the resolver php scripts execute. If so, this could bite someone down the road when a change to the script changed the install order.

    I know it’s incredibly picky, but it bugs me when the SPFResponse snippet appears above the SPForm snippet in the tree since SPForm is the main snippet and the one with all the important properties.
      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
      • 22303 MODX Staff
      • 10,725 Posts
      The vehicles are installed in the order they are added to the package.  I’m not understanding what you are describing here at all; related object order will be based on primary keys.
        • 3749
        • 24,544 Posts
        Quote from: OpenGeek at Nov 25, 2008, 10:10 AM

        The vehicles are installed in the order they are added to the package.  I’m not understanding what you are describing here at all; related object order will be based on primary keys.

        I’m not sure how this happens, but I have two snippets: SPForm and SPFResponse:

        SPForm is created first and added to the package first, in the code and confirmed by the progress messages during the build.

        In the database, SPForm has the lower ID number (so obviously you’re right about it being installed first),  but it’s listed second when I browse the DB. It also appears second in the tree.

          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
          • 22303 MODX Staff
          • 10,725 Posts
          Quote from: BobRay at Nov 25, 2008, 04:05 PM

          In the database, SPForm has the lower ID number (so obviously you’re right about it being installed first), but it’s listed second when I browse the DB. It also appears second in the tree.
          Sounds like some kind of replace statement is setting the primary keys specifically which can mess up the natural order of the records. Is a resolver doing something with these records or are these being inserted as related objects?

          Simply sorting by snippet id would be the solution; should be a simple fix to the tree, but obviously won’t help when you browse the database in phpMyAdmin (or whatever). For a permanent fix to the table you would need to go to the operations tab in phpMyAdmin and reorder the rows by the id column.
            • 3749
            • 24,544 Posts
            Quote from: OpenGeek at Nov 25, 2008, 04:17 PM

            Sounds like some kind of replace statement is setting the primary keys specifically which can mess up the natural order of the records.  Is a resolver doing something with these records or are these being inserted as related objects?

            Simply sorting by snippet id would be the solution; should be a simple fix to the tree, but obviously won’t help when you browse the database in phpMyAdmin (or whatever).  For a permanent fix to the table you would need to go to the operations tab in phpMyAdmin and reorder the rows by the id column.

            I don’t care about the DB, just the order they appear in the tree. Having the Manager sort the tree by element ID within each category would make me a happy camper and would let others control the order of appearance of their elements.

            I am adding the snippets to a category (in the same order they are created) with a related object operation, but I don’t think that’s doing it.

            A PHP resolver that runs at the end of the install is setting properties on the SPForm snippet. I added code to just get and save the SPFResponse snippet after that, which moved it down in the DB, but that isn’t working any more.

            A little reading on MySQL suggests that the natural order is undetermined (which explains why they kept moving around on me), so sorting the items for the tree seems like the only reliable solution.
              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
              • 28215
              • 4,149 Posts
              Quote from: BobRay at Nov 25, 2008, 04:33 PM

              Having the Manager sort the tree by element ID within each category would make me a happy camper and would let others control the order of appearance of their elements.
              See r4488, recently comittted. Tell me if that works.
                shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
                • 3749
                • 24,544 Posts
                It made the snippets and chunks in categories disappear from the tree. Maybe not the best solution.  wink

                (The category folders still show.)
                  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
                  • 28215
                  • 4,149 Posts
                  Quote from: BobRay at Nov 25, 2008, 04:52 PM

                  It made the snippets and chunks in categories disappear from the tree. Maybe not the best solution. wink

                  (The category folders still show.)

                  Huh? Mine isn’t doing that at all. Anything in the error.log?

                  Have you updated in a while? Does running an upgrade setup help any?
                    shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
                    • 28215
                    • 4,149 Posts
                    Ah crap, nevermind. Check r4489.
                      shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
                      • 3749
                      • 24,544 Posts
                      Quote from: splittingred at Nov 25, 2008, 05:03 PM

                      Ah crap, nevermind. Check r4489.

                      That seems to have done it. Thanks!

                      Man you guys are fast! grin
                        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