In the introductory post, I explained briefly what we’re going to create, made some important disclaimers, and blew some hot air around. In this part, we’re going to get our hands dirty by diving in and writing the PHP script and testing it outside of MODx to make sure it works. In general, I think this is a good idea because it allows you to iron out any purely PHP issues in your code before dealing with the MODx side of things. Chances are that even after you’ve tested it and ported it into MODx, you’ll end up adding more PHP logic and stuff but if you can test most of it outside MODx first, it should potentially save you some headaches and debugging time when working inside MODx. This is especially important because once inside the MODx editor there’s no syntax highlighting, automatic indenting and all that other good stuff.
With that in mind, let’s go ahead and create our script.