0

I am working on an Expression Engine site where the "save templates as files" has been disabled.

// config/config.master.php
$env_config['save_tmpl_files'] = 'n';

I'm assuming this means that the templates are stored in the database instead of being served from the files. I have made changes to some template files (header and footer partials). How can I load those changes into the production database?

Part 2 of this question is whether or not this is the right approach and how best can I deploy these changes.

2 Answers 2

1
  1. Download a production database dump and import it to your local database. You will want to make sure your templates are up-to-date with the templates in production.

  2. Enable "save template files" config:

    // config/config.master.php
    $env_config['save_tmpl_files'] = 'y';
    
  3. Locally, go to the admin control panel, go to Design > Templates > Synchronize Templates and sync all the templates. This will try to create/update the template files using data from the database. You may need to adjust file/directory permissions if there are errors while trying to sync.

    Synchronize Templates

    If the template you will be working on is not listed, then you will need to make sure the template is set to save as file before syncing. Navigate to the file in the Template Manager and check the box to "save template as file".

    save template as file

  4. Now you can make your changes to the template files

  5. Repeat step 3 to sync your file changes to the database.

  6. Commit your changes to your git repo.

  7. Deploy to production. The config change should have also been deployed.

  8. In production, repeat step 3 by going to the admin control panel Design > Templates > Synchronize Templates and sync all the templates. Again, if you don't see the template you updated in the list, you need to go find the template and enable "Save Template as File". However, in this step, you want to sync changes from your files to the database. You'll probably need to deploy a second time (or touch the file) so that the template file's modified time is newer than your database change. Then try again to sync the template change.

  9. Now, locally, you can return your config file to the original state:

    // config/config.master.php
    $env_config['save_tmpl_files'] = 'n';
    
  10. Commit this change to your git repo.

  11. Redeploy the config change.

0

You have to enable the save templates as files back and then synchronize the templates. After that, you can disable it again.

Yeah, it's annoying.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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