Yeah, that's a good explanation, and a really interesting use case for the collection tree.
First, the basic fix to not displaying subcollections is in this github commit. Keep in mind this will affect both the dropdown and the collections browse page if you are using it.
After that, I see two different routes that might do the trick. One is a hack on the theme you are using, and one is a hack on the CollectionTree plugin itself.
I haven't worked through the details of hacking the plugin, but it would basically amount implementing the items_browse_sql
hook so that it checks whether a collection has been set in the $params
argument, then digs up the subcollection ids and alters the SQL query to join in items in those subcollections. If my SQL skills were stronger, I'd have tried that route.
The other, somewhat dirtier way, is to alter the items/browse.php
page for your theme to do a similar job.
Here's about what it would look like. In that file, before the line displaying the page title, add this:
<?php
//dig up the request parameters, which will say whether there's been a search by collection
$request = Zend_Controller_Front::getInstance()->getRequest();
$requestArray = $request->getParams();
if (isset($requestArray['collection'])) {
$collectionId = $requestArray['collection'];
$childCollections = get_db()->getTable('CollectionTree')->getChildCollections($collectionId);
$allItems = $items; //items is just what's in the direct collection, so start there
foreach ($childCollections as $childCollectionArray) {
$allItems = array_merge($allItems,
get_records('Item',
array('collection_id' => $childCollectionArray['id'])
)
);
}
set_loop_records('items', $allItems); //make the loop of items include all the subcollection items
$total_results = count($allItems); // change total items count to reflect everything
}
?>
Changing the theme that way is a bit messier, in that it breaks the separation between plugins and themes, but it might also be quicker. With more complicated variations on this code, though, it would also offer the possibility of creating separate sections for each work, thus distinguishing the manuscripts by their collection in the results page.