Hy,
i changed the isfolder field in the site_content table from Database and not from inside modx because i don´t want do update every field manualy. But now i saw that the URI Field for SEO Friendly Urls are only updated if i change the alias field and save the Resource. Is there a function to write global the URI new for every Resource? If i need to do this for over 200 resources it needs much to long.
Thx
I think you could do it with a snippet. Something like this:
$resources = $modx->getCollection('modResource');
foreach ($resources as $resource) {
$alias = $resource->get('alias');
$uri = // whatever you want;
$resource->set('uri', $uri);
$resource->set('uri_override', 1);
$resource->save();
}
I would try it with a single resource first, using
$resource = $modx->getObject('modResource', array('pagetitle' => 'TestPage'))
instead of getCollection() until you’re sure it works.
-
MODX Staff
- 10,725 Posts
If you change the isfolder field via the API and save() the Resource, it will automatically updates all the child Resources if any data changes what the calculated URI would be.
Thanks for your help the URIs are now updated