Hello,
I’m trying to figure out how to list some documents on the front end according to user group permissions.
I have a very basic test page that lists all the resources with a certain parent using something like the following:
$docArray = $modx->getCollection('modResource',array(
'parent' => 4
));
foreach ($docArray as $doc){
$titles[] = $doc->get('pagetitle');
}
// output titles as html list
This all works as expected until I configure resource group access, at which point I get a little confused.
The next steps I’ve taken:
- Add one of the resources, we’ll call it "Product A.1", to a resource group, say "Product Set A"
- Add web user to a user group "Customers"
- Next I update the "Customers" resource group access to include "Product Set A" with a minimum role of "Member", an access policy of "Resource" and a context of "Web"
Now when I go back to the front end, login and hit the test page, the resource "Product A.1" is no longer on the list even though, AFAIK, the current has all the necessary permissions.
I’m guessing that the getCollection method maybe doesn’t handle group permissions by default and that my code will have to handle this, but I have no idea where to start. I’ve read through the documentation and have been perusing the API as well, but I’m pretty much a n00b so it’s a bit daunting. Any help/code examples would be greatly appreciated!