From 0733292c16ff9fe07049a2375df6869e4aa37384 Mon Sep 17 00:00:00 2001 From: manu37 Date: Thu, 7 Nov 2013 12:39:20 +0100 Subject: [PATCH] extend babel plugin OnResourceDuplicate for nested resources OnResourceDuplicate: proper TvInitialize for nested resources/resources with children. --- .../babel/elements/plugins/babel.plugin.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/core/components/babel/elements/plugins/babel.plugin.php b/core/components/babel/elements/plugins/babel.plugin.php index fc804bb..6c0ab15 100644 --- a/core/components/babel/elements/plugins/babel.plugin.php +++ b/core/components/babel/elements/plugins/babel.plugin.php @@ -286,7 +286,19 @@ case 'OnResourceDuplicate': /* init Babel TV of duplicated resources */ $resource =& $modx->event->params['newResource']; - $babel->initBabelTv($resource); + + function initBabelTvsRecursive(&$modx, &$babel, $resource = null, $depth= 100) { + if ( $resource && $depth > 0) { + $children = $resource->getMany('Children'); + foreach ($children as $child) { + $processDepth = $depth - 1; + initBabelTvsRecursive($modx, $babel, $child,$processDepth); + } + $babel->initBabelTv($resource); + } + } + + initBabelTvsRecursive($modx,$babel,$resource); break; } -return; \ No newline at end of file +return;