Skip to content

Instantly share code, notes, and snippets.

@oksushi
Created October 29, 2011 03:34
Show Gist options
  • Save oksushi/1324041 to your computer and use it in GitHub Desktop.
Save oksushi/1324041 to your computer and use it in GitHub Desktop.
If you forget to set the alias with bulk-created resources in MODX, this will help you adjust them
<?php
//
// Create Alias
// Receives a template and a new alias and will adjust the alias of each of those docs
$template = $modx->getOption('template',$scriptProperties,'1');
$newAlias = $modx->getOption('alias',$scriptProperties,'1');
$changeddocs = $modx->getCollection('modResource',array(
'template' => $template
));
foreach($changeddocs as $thisdoc){
$thisdoc->set('alias',$newAlias);
$thisdoc->save();
}
//profit!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment