Created
April 4, 2014 08:35
-
-
Save benjamindean/9970549 to your computer and use it in GitHub Desktop.
MODX Revolution Plugin that saves all your Chunks and Snippets to the external files (in category folders) right in the Root directory. Save the plugin, go to "System Events", check "On Manager Cache Update", Refresh cache from Dashboard, Disable Plugin.
This file contains 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 | |
$chunks = $modx->getCollection('modChunk'); | |
$snippets = $modx->getCollection('modSnippet'); | |
foreach ($chunks as $chunk) { | |
$content = $chunk->getContent(); | |
$category = "SELECT category FROM `modx_categories` WHERE id = " . $chunk->get('category') . ""; | |
$query = $modx->query($category); | |
$aCategory = $query->fetch(PDO::FETCH_ASSOC); | |
mkdir('../chunks/'.$aCategory['category'], 0755, true); | |
$file = '../chunks/'.$aCategory['category'].'/'.$chunk->get('name').'.tpl'; | |
$handle = fopen($file, 'w') or die('Cannot open file: '.$file); | |
fwrite($handle, $content); | |
} | |
foreach ($snippets as $snippet) { | |
$content = $snippet->getContent(); | |
$category = "SELECT category FROM `modx_categories` WHERE id = " . $snippet->get('category') . ""; | |
$query = $modx->query($category); | |
$aCategory = $query->fetch(PDO::FETCH_ASSOC); | |
mkdir('../snippets/'.$aCategory['category'], 0755, true); | |
$file = '../snippets/'.$aCategory['category'].'/'.$snippet->get('name').'.php'; | |
$handle = fopen($file, 'w') or die ('Cannot open file: '.$file); | |
fwrite($handle, $content); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment