Calculate SUM of sub-collections items


By following coding suggestions provided by "patrickmj" here


- (thanks Patrick!!) and modifying the code a bit, I managed to get something like that in my Collection_Tree page.


Ignore the Greek, the image shows a parent collection followed by 4 sub-collections, followed respectively by a number which is the "total_items" in each collection.

My question: How can I get the parent collection number to show the SUM of total_items in sub-collections, in this case, number seven (7)??



I think that you would have to add them up by looping through the subcollections. You could probably do it using something very similar to the loop you have now, but instead of echoing out the info about subcollections, store it all in a long string of html in a variable. Along the way, you can add up the total then echo it out, then echo out the html for actual display of the subcollections.

Thanks Patrick, I've been waiting for your reply. Would you be kind enough to provide me the code? Unfortunately, I understand the code I read but I fall behind when it comes to write new things myself...

If this is too much for a request, please accept my apologies!