Gallery icon indicating copy to clipboard operation
Gallery copied to clipboard

Feature: Enable &depth parameter

Open FickleLife opened this issue 13 years ago • 11 comments

so that all images in child galleries can be retrieved from a parent

FickleLife avatar Jan 05 '12 17:01 FickleLife

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

yurkobb avatar Jan 18 '12 14:01 yurkobb

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.

FickleLife avatar Jan 18 '12 16:01 FickleLife

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.

yurkobb avatar Jan 18 '12 21:01 yurkobb

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?

FickleLife avatar Jan 19 '12 10:01 FickleLife

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.

yurkobb avatar Jan 20 '12 00:01 yurkobb

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!

FickleLife avatar Jan 20 '12 10:01 FickleLife

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?

yurkobb avatar Jan 20 '12 11:01 yurkobb

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

FickleLife avatar Jan 20 '12 12:01 FickleLife

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 avatar Jan 20 '12 13:01 yurkobb

Yurkobb, if you can submit it as a single pull request, isolated from other features, I'll take a look at it. :)

Thanks!

splittingred avatar Jun 19 '12 13:06 splittingred

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.

yurkobb avatar Jun 19 '12 13:06 yurkobb