Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Refresh all static elements entirely
<?php
/**
* Refresh all static elements entirely
* MODX Revolution
* @author goldsky@virtudraft.com
*/
define('MODX_API_MODE', true);
/**
* CHANGE this reference to the main index.php!
*/
include '../../www/index.php';
$elements = array(
'modChunk',
'modPlugin',
'modSnippet',
'modTemplate',
'modTemplateVar',
);
foreach ($elements as $element) {
$statics = $modx->getCollection($element, array(
'static' => 1
));
if ($statics) {
foreach ($statics as $static) {
$static->setContent($static->getFileContent());
$static->save();
}
echo $element.' is done<br>';
}
}
die('finish');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment