It would be great to hide deleted resource elements in the tree view in the manager. Since 2.7 has a trash management page it is not necessary to see the red strike-through resources in the tree view anymore.
Maybe it could be activated via a system setting to hide deleted elements from the tree?
MODX 2.7, php7.2
Found in the table _modx_site_content_ the field _show_in_tree_ and the getnodes.class.php file in core\model\modx\processors\resource\getnodes.class.php interprets this field in the where statements.
If I switch the _show_in_tree_ value from 1 to 0, the element is hidden in the treeview but still exists in the trash manager, which is exact the behavior I was asking for.
So we can simply use a plugin which handles the hiding:
OnResourceDelete / OnResourceUndelete
<?php
$currentResource = $modx->event->params['resource'];
if ($modx->event->name == 'OnResourceDelete') {
$result = $currentResource->set('show_in_tree',0);
$currentResource->save();
} elseif($modx->event->name == 'OnResourceUndelete') {
$result = $currentResource->set('show_in_tree',1);
$currentResource->save();
}
Changing any resource field (except of deleted and deletedon/deletedby) is not the right way to hide those resources in the tree. There has to be a system setting and in the getnodes query deleted resources have to be excluded.
Hey Jako,
I totally agree with you. The above mentioned plugin has some difficulties with other extras that hide resources. It's a simple workaround and the feature should be implemented in the core.
At the Russian-speaking forum there was a discussion about the new format of deleting resources: _if there are a lot of them, then all the resources cannot be deleted at once, the pagination in the deleted resources manager interferes_.
Perhaps in addition to the setting "Hiding remote resources from the tree," we can also make the setting "Use delete manager or not", which will enable the manager or allow you to delete resources in the old way.
Most helpful comment
Changing any resource field (except of deleted and deletedon/deletedby) is not the right way to hide those resources in the tree. There has to be a system setting and in the getnodes query deleted resources have to be excluded.