We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27708 MODX Staff
    • 2,502 Posts
    I wonder if there is any best approach or thoughts on how to go about converting 0.9.x.x snippets to Revolution. Certainly the API is a starting point but I wonder if there is some way to best do this?

    Thanks for any help for a non-dev.

    Jay
      Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. Blog ✦ Twitter ✦ LinkedIn ✦ GitHub
      • 22303 MODX Staff
      • 10,725 Posts
      There will be a migration guide which will cover the topics that will be most important when converting. Unfortunately it’s way too much for a single post in the forum though.

      However, look for direct SQL or calls to the DBAPI first and convert those to use PDO or the new xPDO objects representing the tables, where appropriate. In general SQL should be encapsulated in the classes of the model in a way that can be easily converted to another database engine. xPDO provides mysql-specific versions of those classes now; you just need to put platform-dependent SQL in those classes (or some of your own representing custom tables). Ultimately, snippets should call functions, instantiate objects, and call methods on those objects; this will make the platform much more maintainable and extensible moving forward, by abstracting the implementation of those functions from the code which makes use of them, allowing them to easily be changed without breaking anything.

      The other thing is to start seeing which functions are deprecated, and finding ways to replace their usage. By doing this, developers can also help us better identify the methods that need to be available in various places in the core to support component building in the most robust and efficient way possible. I’m working on a major API documentation push and reviewing the API in total right now in fact to help do the same..
        • 3749
        • 24,544 Posts
        This is a good topic. I have a section on migrating to Revolution at bobsguides.com, but there is really nothing there on converting snippets.

        My method has been to just paste the snippets in and run them and fix each problem that shows up in turn. That doesn’t address the fact that there are things that should be converted to the new Revolution way of doing things even though they work, though.
          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
          I’ve posted a few tutorials on coding for Revolution:


          And a more comprehensive guide will be out as we move to beta.

          It’s hard to define, however, how to convert snippets, as some snippets wont take much converting, and some will. It’s somewhat in need of a case-by-case basis.
            shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com