02 Apr 07

EE Module Release: Templates 2 Files

In Scripts & Resources, Expression Engine

The ability to edit templates directly through the Expression Engine control panel is certainly useful, but personally I favour the creature comforts of a fully featured text editor rather than limited HTML textareas. As a result I tend to have the ‘save template as file’ option set for each and every template, which currently means updating each template manually in order to have a file generated from the template data in the database. Or at least it used to. Templates2Files is a very simple module which takes any templates that do not have the ‘save as file’ option set, creates the corresponding file and updates the db accordingly.

Usage info and further details are available in the readme enclosed. Although I’ve had no problems with the module myself it is probably a good idea to backup your database and templates folders before using it, just for safety’s sake.

Comments and suggestions welcome, as always.

» Download Templates2Files

Posted by Dom Stubbs on 04/02 at 03:52 PM | Trackback
  1. Posted by yoshi on 03/04/07 at 01:35 AM | Link

    This is definitely useful. It’s too bad though that I it doesn’t port file => db, since that’s pretty much what I’m looking to do.

    Although the option of creating the files in one fell swoop is very very useful. When I create new template groups, I often have to click on each template in order to save to file. This gets old after a while!

    Thanks for this!

  2. Posted by Dom Stubbs on 03/04/07 at 10:01 AM | Link

    No problem Yoshi. As I tend to save all my templates to files and leave them there for the duration a bulk import feature wasn’t going to be all that useful to me personally, however I’m definitely not ruling it out for the future if there’s demand.

  3. Posted by yoshi on 04/04/07 at 07:41 AM | Link

    I found an issue with this. when it creates the files, there’s a stylesheet issue, but that’s not the real issue. the real issue is permissions. because the webserver creates them, it’s not appropriately making the permissions to 666 or 777 (for directories) which makes it tough to edit them through ftp. smile

    I’m sure it’ll be different for many servers, but on mine, that’s the issue.

  4. Posted by Dom Stubbs on 04/04/07 at 09:18 AM | Link

    Interesting yoshi, thanks for the update. I’m a little confused how the default permissions cause any issues with FTP editing though? I’m assuming they’re being produced as 755/644 (I developed this module on Windows) and if so that should ensure they’re capable of being downloaded and overwritten right from the off. Could you expand a little?

    Also what problems have you had with stylesheets?

  5. Posted by yoshi on 04/04/07 at 04:02 PM | Link

    well, since the permissions are 755/644, and the owner is the web server, as the user, I don’t have permissions to overwrite the files. rasberry In addition, I can’t create files either. hehe.

    I fixed the issue by creating a php file that changed the permissions though. smile so all is good now. hehe.

  6. Posted by Dom Stubbs on 04/04/07 at 04:49 PM | Link

    Well what has me confused is that every server environment I’ve used (both Windows and *nix) has been fine about allowing the FTP user to modify files created by the web server, perhaps that’s just a strange coincidence.

    Since you mentioned this I have had a nose around the standard EE setup though and it does appear that any directories and files it creates are set to 777/666. Since I’m aiming to duplicate the standard behaviour it looks like I’ll be making an update shortly. wink

    I’m glad you have a solution for now; hopefully I’ll be able to find the time tomorrow to sort an update so that nobody else has the same problem.

    Thanks again for pointing this out.

  7. Posted by yoshi on 04/04/07 at 05:07 PM | Link

    Well if it helps, the environment is unix with cPanel. I know in unix if the webserver creates a file, it creates it as the webserver user, in which case, on many machines for security purposes is apache or something to that effect.

    So it can get crazy. it’s always just safer to just chmod the files manually to be sure it’s like that I think. Actually I’m not sure how EE does it natively. i’ll have to poke in the code.

  8. Posted by yoshi on 04/04/07 at 05:08 PM | Link

    Oh crud, I forgot to mention another thing. It would be nice to be able to choose which templates are checked instead of all of them. I only say this because I have a couple of “dummy” template groups that don’t do anything, just to separate and keep it organized. obviously i don’t want those done. rasberry

  9. Posted by Dom Stubbs on 30/04/07 at 05:20 PM | Link

    Oops. I could’ve sworn I replied to this, but I can only assume it was the related thread on the EE forums.

    In short the module has now been updated to include the correct (i.e. 0777 folders, 0666 files) permissions all round.

    Regarding the selectable templates I can’t see myself implementing that in all honesty. What’s the harm in having the files created for those ‘dummy’ groups?

Commenting is not available in this site entry.

Posts

November 2008
S M T W T F S
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30            

QuickLinks