Let me see if I get it. You want to put all resources that are children of another resource into the same resource group? You don't want resources at the root level of the tree in that group, but all other resources should be?
If that's it, this plugin would do it (connected to OnDocFormSave):
if ($resource->get('parent') != 0) {
$resource->joinGroup('MyResourceGroup);
}
If will only work when you save a resource, and I don't think it will work with Quick Create.
ok so the only way is with a plug-in
I thought I could do with MIGXdb (something like "Set the Template for our children")
thanks Bob
----------------------------------
canale irc Italiano #modx server: tophost.azzurra.org
I'm not that familiar with MIGX, so it might be possible. I tend to use plugins for everything like that.
the childresourses-update-processor uses the modx-resources-create/update-processors. So I think a plugin should work.
you can also create a custom-update-processor in a new directory and specify the processors-path in the MIGXdb - configuration.
hi Bruno
yes OnDocFormSave plugin work
<?php
$templateObj = $resource->getOne('Template');
if(!$templateObj){
$modx->log(modX::LOG_LEVEL_ERROR, "template empty");
return false; //exit plugin
}
$templateObjName = $templateObj->get('templatename');
$templateValid = array("articolo_cliente");
//check Template
if(in_array($templateObjName, $templateValid)) {
if ($resource->get('parent') != 0) {
$resource->joinGroup('Clients Only');
}
}
----------------------------------
canale irc Italiano #modx server: tophost.azzurra.org
hi Bruno
yes OnDocFormSave plugin work
great! Thanks for reporting
If you look in the parentheses next to the template in the Element tree, you'll see its ID. This would be significantly faster and more reliable (it doesn't get the entire template object for every save -- which you don't need -- and it will still work if you change the name of the template ):
<?php
// if (! $mode == modSystemEvent::MODE_NEW) return '';
$templateId = $resource->get('template');
if ($templateId == 12) { /* replace 12 with template ID */
if ($resource->get('parent')) {
$resource->joinGroup('Clients Only');
}
}
Uncomment the first line once all existing resources are in the group that should be. That will make it even faster because you only need it for new resources.
right! thanks for the tips Bob
----------------------------------
canale irc Italiano #modx server: tophost.azzurra.org