Hi. And welcome to the forums.
There are, as with most things MODX, several ways to achieve what you want.
One official way would probably be to create a User Group, add the User to that User Group. Then create a Resource Group and add all resources to it, but not res3. Add Resource Group to User Group and give Resource Group an Access Policy where add_children is not allowed.
This is just off the top of my head, but should work with a little tweaking. But sounds rather complicated, doesn't it? Well, it is, kind of. But very powerful, once you get the hang of it (like i am still trying very hard). If you intend to work with MODX regularly, i recommend you read some tutorials on it and give the whole Access Controls thing a try.
Meanwhile there is another quick-and-dirty way to do what you want:
- create a new Plugin
- under System Events enable the row OnBeforeDocFormSave
- put following code in 'Plugin code (PHP)'
// enter here the ID of res3
$allowedParentResourceId = 123;
// checking if a new resource is being created
// (other value would be 'upd' for update
if( $mode === 'new' ) {
// if new parent ID is not res3...
if( $_REQUEST['parent'] != $allowedParentResourceId ) {
// ...send error message to User,
// which also prevents resource from being saved
$modx->event->output('You cannot create a document here!');
}
}
I think this should do it for your example. But mind that if you wanted anything more complex, Access Controls would probably be the better choice.
Edit:
this would of course prevent any user, also the admin, to create any resource anywhere but under res3. If it is a very static website, maybe it would even be ok to just deactivate the plugin, if another resource needs to be created. If not, you would still need to create a User Group, add that User to it and check in the code, if active user belongs to the User Group.
[ed. note: itWillBeOk last edited this post 12 years, 5 months ago.]