As someone who likes to work with a proper code editor rather than a HTML form I’ve found it a bit frustrating having to ‘update’ individual templates in order to generate template files to work with. Since I’ve also fancied getting my head around how modules work for a while it seemed like a good opportunity to kill two birds with one stone.
Templates2Files makes it possible to generate files for every template in your system in one click. Other than that there’s not much I can say about it. If a template is already set to be saved as a file then it will not be overwritten with what’s in the database. There’s a little more info on precedence in the readme enclosed.
Hopefully this is of use to a few people rather than just me! 😊
The database is still queried when a template is accessed if you are saving them as files; the content of the template itself is of course pulled from the file, but the database still has to be queried for all of the meta information, access restrictions, etc. So if there is going to be a performance hit, it would occur when templates are saved as files, on servers with slow disk arrays. For most people, this is going to be a matter of thousandths of a second, so is insignificant. On large, high traffic sites, with optimized MySQL servers, I tend to recommend returning the templates to being saved in the database when development is finished, though I have never seen empirical or anecdotal evidence that there is any appreciable difference.
Glad to hear it’ll be of use. I have to admit, I’ve not used the module myself for some time, so if there are any issues with recent EE versions I’m not yet aware of them. I would be surprised if there were though, as I can’t recall any alterations to the templates section of the database.
I think there may be one complication here that may have arisen since the arrival of the Multi Site Module (MSM).
It looks like Templates2Files uses the Global Template Settings (specifically, the base location of the path to save the files) from the currently active site, and applies this to all templates, from all sites, thus saving all the templates to the same location.
This wouldn’t be necessarily problematic (as each template group gets its own subfolder), except that you might (like me) have template groups in different sites with the same name (‘search’, ‘inc’, for example).
This resulted in all the templates from all the ‘inc’ template groups ending up in one folder, and where there are duplicate template names (I have a number of ‘inc/footer’, ‘inc/header’ templates), only the first of each was copied.
I deleted the ‘common’ folders created by Templates2Files and generated them one at a time using the EE edit / save as file ’ process, but I thought I should post this in case someone else finds themselves in the same position.
Okay - I tried to use this module, but when I go to create the flat files I get this error:
Warning: Output::require(./system/core/core.typography.php) [function.Output-require]: failed to open stream: No such file or directory in /path/to/system/core/core.output.php on line 478
Fatal error: Output::require() [function.require]: Failed opening required './system/core/core.typography.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /path/to/system/core/core.output.php on line 478
edit - despite the above error all the flat files appear to have been accurately created.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.