I wrote a snippet that will let me edit my MODx contents directly, especially snippets and plugins (update the database directly).
After the edit, MODx will not use the new snipper/plugin. It will still use the old snippet/plugin. I need to do a ’refresh’ by either clicking on
’clear cache’ in the manager, or edit and save
anysnippet or plugin in the manager.
I try to look at the source codes of MODx for ’clear cache’ and also saving snippet and plugin. All I can found was some lines of cache clearing code, so I add them as well to my snippet in hope that everytime I edit my snippet/plugin manually using my snippet, I do not need to go into manager and ’clear cache’.
function clear_cache()
{
global $modx;
include_once($modx->config('base_url') . "manager/processors/cache_sync.class.processor.php");
$sync = new synccache();
$sync->setCachepath($modx->config('base_url') . "assets/cache/");
$sync->setReport(false);
$sync->emptyCache();
$modx->clearCache(); // double clear cache
}
The above code doesn’t work for me. Am I missing anything? The above code do works well on refreshing site content but not snippet, plugin and chunks.