I see. I've never written a MODX plugin before. Is the learning curve steep? Also, there are over 4100 resources already in this container. Is there an easy way to change all of those without doing each one manually?
Thanks!
It depends on whether there is a fixed pattern for creating the uri from the existing alias or pagetitle. If there is, it's usually a pretty simple job for a snippet to set them all (and the same code could then be moved into the plugin).
A snippet like that, could change all uris for you:
<?php
$parent = '9999999';
$uri_path = 'news/';
$c = $modx->newQuery('modResource');
$c->where(array('parent'=>$parent));
if ($collection = $modx->getIterator('modResource',$c)){
foreach ($collection as $object){
$object->set('uri',$uri_path. $object->get('alias'));
$object->set('uri_override','1');
$object->save();
}
}
the plugin - code could look like that:
<?php
$parent = '9999999';
$uri_path = 'news/';
if ($resource->get('parent') == $parent) {
$resource->set('uri', $uri_path . $resource->get('alias'));
$resource->set('uri_override', '1');
$resource->save();
}