Hello,
I use MODX 2.2.10
wampserver 2.4
apache 2.4.4
php 5.4.12
mysql 5.6.12
I have some resources with differents permissions access. The permissions works fine but I use GetResources snippet on my home page to get only 4 ressources. This is where the issue is.
WHAT I WANT
for connected users : I want to see 4 ressources on the home.
for anonymous web users : I want to see 4 ressources from the ones allowed.
WHAT I HAVE
for connected users : see 4. all is OK
for anonymous web users : see only 3 (while I have more than 4 allowed resources for anonymous web users).
It looks like getRessources applied the limit before the permissions. Is it the normal behavior of getResources ? Or is there a way to configure it to make it work ?
[ed. note: cloughy last edited this post 12 years, 9 months ago.]
Good question. I wonder if a solution was found?
I'd have to look at the code to be sure, but my guess is that the limit is part of the DB query and getResources then loops through the results and checks permissions. If I'm right, there's no way to change that behavior without hacking the getResources code (and it would be a difficult hack).
I can think of a couple solutions:
1. Use your own code to do what getResources does, but impose the limit after the permissions are checked. If your criteria for the search is simple (e.g., all children of a specified parent), it should be fairly simple.
2. Call getResources without the limit in your own snippet with $modx->runSnippet(), then truncate the results before returning them. You can put some kind of marker (e.g., ###) at the end of your Tpl Chunk, explode the results using that marker as a delimiter, then return the number of entries you want.
There may be an easier way, but offhand I can't think of one.