I'm working on a site with hundreds of templates that were all saved in the database. If I run a query to change "save_template_file" to "y" and then run synchronize, will that work? Any horror stories around doing this?

  • I'd imagine this would work just fine. Jan 11 '13 at 21:37

Does running the query & sync create the files? In the past I've had to export all the templates. That will create a default_site.zip open that, dump that into where I'm saving templates and then run the query to change save_template_file to 'y'

  • 2
    Yea, I ran a test on a group and changed the "save_template_file" to "y" and it seemed to work as expected. Going to try it on a few more groups and see if there are any issues. Edit - Wow, I had no idea the export worked that well. It did indeed create all of the templates and it was extremely fast. I was mostly worried that doing 500+ templates would cause some issues. Thanks for that tip! Jan 11 '13 at 22:58
  • yeah, was only a recent discovery for me as well on a large build I took on. That said, most of the templates were crap! Jan 11 '13 at 23:17
  • haha, yes, we are trying to deal with 500+ templates that are ALL managed in the CP. I have no idea how organizations can get anything done this way, esp with so many embeds. As they say on Reddit, have an upvote, my friend! Jan 11 '13 at 23:29
  • 1
    Just a note, that just because they aren't saved to file, DOESN'T mean that they were all managed through the control panel. You can directly mount the database templates as files, using Mountee or other add-ons. That's my preferred method. Feb 2 '13 at 21:23

The query you'd use to change all templates to be saved as files is:

UPDATE `yourDBname`.`exp_templates`
SET `save_template_file` = 'y';

And if you wanted to limit it to only a certain group you'd use the following:

UPDATE `yourDBname`.`exp_templates`
SET `save_template_file` = 'y' 
WHERE `exp_templates`.`group_id` =X;

Change out yourDBname for your actual database name in both cases and change X for the number which equals your template group_id number in the second case.

You could run this direct from the SQL tab in PMA (phpMyAdmin) or using a tool like Sequel Pro or Navicat etc.

Make sure you have a DB backup first of course!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.