-
-
Save pepebe/fe72914ec5da30c578373ea345cb3cc8 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
This file contains hidden or 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 | |
/* | |
* 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 : [email protected] | |
* | |
* @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