Progress has slowed a bit while I migrated to a new server and cleaned things up, and rehabilitated my Git infrastructure. Prior to that, I’d been doing a lot of research about how I’m going to proceed with TightURL.
I’ve been seeding hooks throughout the code, and a concentration of them ended up in the template code. One of the things I’ve always been uncomfortable about in TightURL is the template system. One of my long time pet-peeves is about everyone creating their own PHP template system, and I ended up doing the same here, just because I really wanted the most lightweight template system I could get. But the discomfort remains to this day, and as a result, if you’re so inclined, you’ll be able to use a plugin to replace either parts or the entire template system.
After cleanup, I’ve got three template hooks, all of which are filters:
- template_fetch : Retrieves a template, can only be used to replace the template retrieval process. Use this if for example, you want to store templates in the database instead of the filesystem. If no plugin causes HTML to be returned by this hook, the template will be searched for in the file system as usual. For the time being, you’ll have to be careful not to use more than one plugin that replaces the template retrieval process, as whichever one runs last will be the one whose HTML is returned.
- template_process: Processes template. If you want to set or change template variables, you set those here by filtering the template variables. If you wish to replace TightURL’s template processing system, you do so here by doing “final” processing and returning the HTML to be displayed. Here again, if you were to try to use more than one plugin that replaces the template processing system, the results would be inconsistent (bad).
- template_filter: Filters the processed template, just prior to display. If you only wish to modify template output before it is sent to the user, this is the filter to use. As with all other TightURL filters named something_filter, more than one plugin can hook into template_filter and modify the output.
The template_fetch and template_process filters combined, will allow plugin developers to completely replace the TightURL template system, and to do so in a way that preserves other plugin developers ability to filter the output before it is sent to the user.