Hi, is it possible in ModX Revo or is there an addon that will let me edit the description field (or any other tv) at once (I have several items that require the same description).
Thanks.
-
☆ A M B ☆
- 24,524 Posts
As far as I know, the closest would be to export the records for those resources as a .csv file, edit the description fields using a text editor, then us ImportX to import them back again.
It would probably be easier to use phpMyAdmin, select the relevant resources, and edit their description fields - copy/paste would speed it up.
There is an add-on called "Group Edit" that might do the job; I'm not real sure how it works, though.
[ed. note: sottwell last edited this post 13 years, 1 month ago.]
Hi,
I know you can batch edit resource properties (eg. published/notpublished, hideinmenu/showinmenu) using Batcher...but I have never seen anything that batch edits resource content. That would be really, really handy though!
Otherwise, you may have to manually manipulate your database if you know your way around phpmyadmin or something like that.
Sar
☆ Flag it! - Don't forget to "star" a reply if it's answered your question
You could do it with this utility snippet, but I'm not sure it would be easier than using QuickEdit to do them in the Manager:
<?php
$field = 'description'; /* field you want to change */
$ids = '12,24,35,97'; /* IDs of the resources you want to edit */
$text = 'New Text for the field';
$docIds = explode(',', $ids);
$output = '';
foreach ($docIds as $docId) {
$doc = $modx->getObject('modResource', (integer) $docId);
if ($doc) {
$doc->set($field, $text);
$doc->save();
$output .= '<br />Changed document ' . $doc->get('pagetitle');
} else {
$output .= '<br />Could not find document ' . $docId;
}
}
return $output;
Note that this is no good for Template Variables (description is not a Template Variable, it's a Resource field). It will only work on text type Resource fields, but it could be modified slightly to do TVs. It won't work for the template or parent fields, unless you use the ID of the template or parent in the $text variable.
Thanks for the replies. I checked out Group Edit, it only allowed me to delete multiple resources, which I already user Batcher for. It would be a nice feature to have, but it seems the quickest option will be to export the resources, get the client to amend the descriptions en masse and re-import with ImportX.
Are they all under a single parent folder or a small group of them?
Ah. Simpler yet.
$field = 'description'; /* field you want to change */
$text = 'New Text for the field';
$parentId = 12; /* ID of the parent resource */
$output = '';
$docs = $modx->getCollection('modResource', array('parent' => $parentId));
$output .= '<h3>Correcting ' . count($docs) . ' Resources</h3>';
foreach ($docs as $doc) {
$doc->set($field, $text);
$doc->save();
$output .= '<p>Updated document ' . $doc->get('pagetitle') . '</p>';
}
return $output;
This assumes that they're all directly under that parent folder.