Created
September 28, 2012 11:30
-
-
Save Mark-H/3799296 to your computer and use it in GitHub Desktop.
Change template for @datarecall #modx
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 | |
$parent = 5; | |
$resourceWithChildrenTpl = 1; | |
$resourceWithoutChildrenTpl = 2; | |
$childs = $modx->getChildIds($parent); | |
foreach ($modx->getIterator('modResource',array('id:IN' => $childs)) as $resource) { | |
if ($resource->get('parent') == $parent) { | |
if ($resource->hasChildren() > 0) { | |
$resource->set('template', $resourceWithChildrenTpl); | |
$resource->save(); | |
} else { | |
$resource->set('template', $resourceWithoutChildrenTpl); | |
$resource->save(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment