We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Templates2Files Module

Development and Programming

Dom Stubbs's avatar
Dom Stubbs
156 posts
18 years ago
Dom Stubbs's avatar Dom Stubbs

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! 😊

Templates2Files Info Download Templates2Files

       
Cocoaholic's avatar
Cocoaholic
445 posts
18 years ago
Cocoaholic's avatar Cocoaholic

Haven’t tried it yet, but it sounds like a great module!

       
Micah Goulart's avatar
Micah Goulart
8 posts
18 years ago
Micah Goulart's avatar Micah Goulart

Sounds like a good module. Where are the files saved? In the same folder where template files would be saved normally?

Also, wouldnt EE be faster if it accessed the templates in the files as opposed to querying the templates db for each page?

       
Dom Stubbs's avatar
Dom Stubbs
156 posts
18 years ago
Dom Stubbs's avatar Dom Stubbs

The files are saved in the same location and with the same structure as EE’s inbuilt ‘save templates to files’ option. As far as performance, I think the difference is pretty negligible but I have never gone out of my way to compare the two options.

       
Derek Jones's avatar
Derek Jones
7,561 posts
18 years ago
Derek Jones's avatar Derek Jones

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.

       
Dom Stubbs's avatar
Dom Stubbs
156 posts
18 years ago
Dom Stubbs's avatar Dom Stubbs

Thanks for clearing that up, Derek.

       
tbritton's avatar
tbritton
714 posts
17 years ago
tbritton's avatar tbritton

I am a fan of this module, and will spread word of it high and wide! (just did, in fact!)

Thanks!

Terry

       
Ryan M.'s avatar
Ryan M.
1,511 posts
17 years ago
Ryan M.'s avatar Ryan M.

I will definitely try this. I’m always working with templates as files. Thanks for sharing this.

I just realized how old the original post is. Wow - can’t believe I didn’t come across this before now (so thanks, tbritton, for awakening the post and spreading the word!).

       
Dom Stubbs's avatar
Dom Stubbs
156 posts
17 years ago
Dom Stubbs's avatar Dom Stubbs

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.

       
tbritton's avatar
tbritton
714 posts
17 years ago
tbritton's avatar tbritton

Works like a charm! No issues here!

(I know lots of people want the reverse Files2Templates thingy where it updates the database with the new template info for search and replace - but the module works fine already as-is.)

Terry

       
ExpressionEngineer's avatar
ExpressionEngineer
148 posts
17 years ago
ExpressionEngineer's avatar ExpressionEngineer

I wrote a simple plugin for this a while back, but I’m sure this module is a better option.

If anyones interested: http://ellislab.com/forums/viewthread/67993/

       
Les McKeown's avatar
Les McKeown
133 posts
17 years ago
Les McKeown's avatar Les McKeown

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.

       
ExpressionEngineer's avatar
ExpressionEngineer
148 posts
17 years ago
ExpressionEngineer's avatar ExpressionEngineer

Thats not an issue with my plugin, I create a subfolder for each site, and place all files & folders in it.

       
Sean C. Smith's avatar
Sean C. Smith
3,818 posts
16 years ago
Sean C. Smith's avatar Sean C. Smith

Wow, this is great - just started working with flatfiles on a client site, but my personal install of EE has 10 groups each with 10-15 templates - definitely going to save me some time.

       
Sean C. Smith's avatar
Sean C. Smith
3,818 posts
16 years ago
Sean C. Smith's avatar Sean C. Smith

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.

       
1 2

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.