Skip to content

Instantly share code, notes, and snippets.

@krismas
Last active October 14, 2021 14:03
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save krismas/3639503 to your computer and use it in GitHub Desktop.
Save krismas/3639503 to your computer and use it in GitHub Desktop.
A small MODX plugin to avoid refreshing - by default - the entire site cache when editing a resource
<?php
/*
* A small MODX plugin to avoid refreshing - by default - the entire site cache when editing a cached resource - (c) 2012 ackwa.fr
*
* @version : 1.0.0
* @see : https://gist.github.com/gists/3639503
* @name : syncpage.php
* @author : g.noel@ackwa.fr
*
* @event : OnDocFormSave, OnDocFormPrerender
*
* @history : 27/06/12 - 1.0.0 - Initial revision
*
* @info : Similar and/or more efficients codes :
*
* - http://bobsguides.com/cachemaster-tutorial.html
* - https://gist.github.com/jpdevries/5732257
*/
switch($modx->event->name) {
/*
* Disable "syncsite" checkbox
*/
case 'OnDocFormPrerender':
$modx->regClientStartupHTMLBlock('
<script type="text/javascript">
Ext.onReady(function() {
var oCBSync = Ext.getCmp("modx-resource-syncsite");
oCBSync.setValue(0);
});
</script>');
break;
/*
* (Re)Generate the current Resource cache
*/
case 'OnDocFormSave':
if (($oResource = $modx->getObject('modResource', $resource->get('id')))) {
$oResource->_contextKey = 'web';
$oResource->setProcessed(true);
$modx->cacheManager->generateResource($oResource);
}
break;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment