Feature: Enable &depth parameter
so that all images in child galleries can be retrieved from a parent
I have that in my fork (it's called &includeChildAlbums there). Also, there was a pull request with this (still unanswered), see pull requests of splittingred/Gallery
Thanks yurkobb - that's great. It seems to only go one level deep - not the whole tree, and I need it to go to 3 levels! I'll have a look at your code and see if I can do it with my limited PHP skills. Fantastic though, that helps me a lot. Cheers.
Oh, you're right. Definitely that needs to be fixed. It should not be hard if you're familliar with some of xPDO. But I may fix it too if you don't want to play with it this time.
I've only done some very basic xPDO reading, writing and querying - but am learning. Having a look at your code though:
$childAlbums = $modx->getCollection('galAlbum', array('parent' => $galleryId));
So it only gets the items that have the id specified with &album as a parent. How would you modify the query to get all children from the id specified in &album?
Ok, seems done. Please have a look on this diff: https://github.com/yurkobb/Gallery/commit/8c61fc5082eb850d4ad1938b2292839b9f837c34
The &depth parameter now defines how many levels to dive under the requested album, and if it's -1, grab all the child albums.
Thanks yurkobb it works well. I had to comment out this line
$this->xpdo->log(xPDO::LOG_LEVEL_DEBUG, FUNCTION.' call. Args: '.implode(', ', func_get_args()));
in the galAlbums class as I was getting an error and &depth=-1 doesn't work, but if you put a high number in it works fine. Thanks very much, this makes life a lot easier!
Thank you for raising the issue, it's a handy feature. And thanks fo debugging! I've fixed the &depth=-1 yesterday but the link still pointed to the initial commit. Please see the last commit. And maybe you have the error from that problematic $this->xpdo-log(...) somewhere in your logs so I can figure out what was going on there?
Great, -1 works in latest commit.
The error I get is: Fatal error: func_get_args(): Can't be used as a function parameter in /home/clearcha/public_html/ccuk/core/components/gallery/model/gallery/galalbum.class.php on line 181
Thanks for the error log. It's due to different php versions that I didn't have this error:) I'll remove that line.
Yurkobb, if you can submit it as a single pull request, isolated from other features, I'll take a look at it. :)
Thanks!
Ok, thank you! I'll try to clean up and maybe optimize the &depth funtionality during a week or so and prepare it as a pull request.