Making an installer for a MODx snippet
13 Oct 2010 MODx
Having done some updates to PubKit that make it worth a release as a new version (0.7.1), I thought I'd have as go at adapting the MODx installer to reduce the overhead of adding all the associated chunks etc. Challenging, and a mixture of fun and frustration as I see light at the end of the tunnel more than a week later! Well, to be honest, I knew that was how it would be.
First experiment was to modify some of the chunks in the normal MODx Evo installer package, putting my own code into the tpl files in install/chunks and updating the names. I'd done some research into PHPDoc previously, and realized that the installer barely scratches the surface of what the package is about, but it helped boost confidence that making the package would be a trivial affair (that I button is for Irony, right?). The key to success is basically the double star at the top of the slashterisked comment block.
Once I'd established chunks could be added quite simply like this, I searched the forums (once again) for any scraps on the MODx installer's little ways. The examples offered by the standard package's chunks, snippets and templates were fine, but I really wanted to know about adding different types of template variables with widgets, parameters and so on. I struck gold in the Release Support board, finding a handy list of the relevant tags from the coding team's garryn.
Half the world is not enough, however. It's all very well you PubKit addicts being saved the bother of copying and pasting all those chunks and snippets, but now you'll just feel hard done by having to create your own pages to put them in, won't you? So I plunged deeper into the recesses of the installer files, and started tinkering with the setup.sql and setup.data.sql files that install the sample website, hacking them about with Notepad++.
I applied my rudimentary MySQL skills to the MODx backup of my own sample's resources, setting variables to stand in for the resource IDs, and substituting double linefeeds for the SQL semicolons, as required by the installer's own MySQL parser.
My installer can now add a PubKit sample mini-site as a sub-tree of the site you run the installer on. You still have to switch the template of the generated resources (a doddle using using DocManager), and I'm still chasing up some problems with aliases and friendly URL paths. I'd also like to avoid having to make config.inc.php writable to run the install, but that can wait for another day.
The plan now is to settle for friendly URLs but not friendly URL Paths for the demo, finally tidy the installer package, then put it to one side while I plod through the other steps for release: update the files and documentation here on PogWatch, post it to the development thread on the forums, then at last offer PubKit 0.7.1, with installer, for the MODx Extras.
Wish me luck!