Created
May 10, 2011 20:03
-
-
Save rsanchez/965260 to your computer and use it in GitHub Desktop.
EE1: Sync template files from DB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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