Quote from: sottwell at Dec 03, 2014, 02:35 PMThere are several ways you can do this. One way is to use the Personalize snippet. Or you could have custom snippets to check the user's permissions for more complex uses. These work with groups, and display one chunk if the user belongs to a specified group or groups, and another chunk if he does not.
http://bobsguides.com/personalize-tutorial.html
Thanks. In my case I'm not sure this is the right fit. I like that they added group checking but MODX is more refined than that. For example it is likely that ALL users will be in a single group called "employees" for example, but some would be separate by roles. The admin, super admin, manager, member, etc.
So I'd rather check for roles or authority than purely group.
Second, I will likely need more freedom in handling the condition than just showing one chunk or a different chunk. More likely I would be calling another snippet entirely, or even changing templates. It might look like this:
* User selects page from menu.
* If user is logged in, the template is loaded.
* The template has snippets to call various page elements, let's say a list of items.
* The list is generated by another snippet, but if user doesn't have X permission or authority or role or group(?), certain items are removed from list.
* Potentially, as the snippet displays the list, if role is yet higher still, say super admin instead of manager, an additional button or link to delete the item is displayed as well.
* If the action to delete or edit an item is given, permissions would have to be checked again I would think.
This is not as simple as just showing one chunk or a different chunk. There is a lot of logic going on. I'd like all this logic, and what to show and not show, be part of the same script. In other words, I don't want to call separate, nearly identical snippets or chunks for each user type (i.e. this chunk for members, that chunk for managers, and this other chunk for admins, etc).
Do you think it's better to test for group, role, authority, or individual permissions?