Skip to content

Commit

Permalink
extend babel plugin OnResourceDuplicate for nested resources
Browse files Browse the repository at this point in the history
OnResourceDuplicate:
proper TvInitialize for nested resources/resources with children.
  • Loading branch information
manu37 committed Nov 7, 2013
1 parent 0e21730 commit 0733292
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions core/components/babel/elements/plugins/babel.plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
return;

0 comments on commit 0733292

Please sign in to comment.