Skip to content

Instantly share code, notes, and snippets.

@zhabinka
Last active July 7, 2017 09:57
Show Gist options
  • Save zhabinka/76f77d675e54cc2fe7178546edcf0f22 to your computer and use it in GitHub Desktop.
Save zhabinka/76f77d675e54cc2fe7178546edcf0f22 to your computer and use it in GitHub Desktop.
Массовая смена шаблонов - https://modx.pro/help/12142/#comment-80598 Есть дополнение Batcher для подобных целей.
$resources = $modx->getCollection('modResource',array('parent' => 19));
foreach ($resources as $res) {
$res->set('template', 3);
$res->save();
}
<?php
$child = $modx->getChildIds(894, 1, array('context' => 'web')); //894 - id, 1 - вложенность
$collection = $modx->getCollection('modResource', array(
'id:IN' => $child,
//'template' => 8,
//'deleted' => false,
));
$output = '';
foreach ($collection as $res) {
$res->set('template', 28);
$res->save();
//$output .= $res->get('id') . ',';
}
//print $output;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment