Skip to content

Instantly share code, notes, and snippets.

@goldsky
Last active June 12, 2018 03:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goldsky/2bced19ca7be8dba067cc283820a6834 to your computer and use it in GitHub Desktop.
Save goldsky/2bced19ca7be8dba067cc283820a6834 to your computer and use it in GitHub Desktop.
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