Skip to content

Instantly share code, notes, and snippets.

@rsanchez
Created May 10, 2011 20:03
Show Gist options
  • Save rsanchez/965260 to your computer and use it in GitHub Desktop.
Save rsanchez/965260 to your computer and use it in GitHub Desktop.
EE1: Sync template files from DB
<?php
//turn on templates as files in Global Template Preferences
//change templates to save as file in Template Preferences Manager
require_once PATH_CP.'cp.templates.php';
global $SESS, $LOC, $DB, $DSP;
if (is_null($DSP))
{
require_once PATH_CP.'cp.display.php';
$DSP = new Display;
}
$cp_templates = new Templates;
$query = $DB->query("SELECT * FROM exp_templates JOIN exp_template_groups ON exp_templates.group_id = exp_template_groups.group_id WHERE save_template_file = 'y'");
foreach ($query->result as $row)
{
$tdata = array(
'template_id' => $row['template_id'],
'template_group' => $row['group_name'],
'template_name' => $row['template_name'],
'template_data' => $row['template_data'],
'edit_date' => $LOC->now,
'last_author_id' => $SESS->userdata['member_id']
);
$save_result = $cp_templates->update_template_file($tdata);
}
echo 'finished.';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment