Seeing that ZenMagick is stuck with sitting on top of Zen Cart for a bit longer [unless I find someone to rewrite all shipping and payment modules for me ] it might be worth spending a bit of time on a new concept for getting around some of the limitations of having all configuration options as defines.
Defines, for those that are not in the know, are somewhat like global constants – once they are created they don’t go away and they definitely can’t be changed. Well, you say, that’s good. Isn’t that what configuration options should be?
I guess the answer is not that straightforward. It seems like a great idea – until you get a project that depends on making one changeable. And then another one. And another one.
So, coming back to the title of this post, multi site is a zencart mod/ZenMagick plugin that allows to use different domains (so potentially different stores) with a single ZenMagick installation. The main issue is that this requires to change some unchangeable settings on-the-fly, depending on the hostname used (mostly).
Right now the mod does this by utilising zencart’s build in support for loading custom settings. There, without changing core files it is possible to create defines based on request data before zencart does. So far this is a fairly custom process that involves having write access to folders and files during installation and generally is quite fragile.
Another issue is that at that point of execution, none of ZenMagick is loaded yet. This makes coding a bit of a pain.
So, I wonder if it would be possible to change all of that by moving the ZenMagick bootstrap code into the optional local/configure.php. To be clear, not all of it, just a single line to load the basics. Sounds great? Uhm, but what about database access? Yeah, true, what about that?
Well, the idea would be to get ZenMagick up to a point where the only things required from the main configure.php are database access details. Those could easily be extracted from the file without loading it and then all other configuration would be available from the database.
From an UI point of view this could mean to have a site/store management page where a new store can be set up and any of the existing configuration options could be set for each store. It could also mean that a lot more zencart code could be not loaded at all and thus saving more processing time. I know it sounds a bit crazy but from a purely coding point of view it seems doable.