I am using Omeka 1.5.3, with the "collection tree" plugin and Jeremy's get_tags_for_items_in_collection from
https://gist.github.com/clioweb/901923 which is listed below.
I really would like to enhance the functionality of this code, so that not just the tags of the specified collection, but also all tags in any children collections or their children would be returned.
How can I...
Determine if the "collection tree" plugin is active.
Get a list of all children and grandchildren of a collection from the plugin tables.
Incorporate that list of collections to the select->where filter.
Thanks for any help.
-Tom
<?php
/**
* Return Tags associated with Items in a given Collection.
*
* @param Collection
* @return array Tags.
*/
function get_tags_for_items_in_collection($collection = null) {
// If collection is null, get the current collection.
if (!$collection) {
$collection = get_current_collection();
}
// Get the database.
$db = get_db();
// Get the Tag table.
$table = $db->getTable('Tag');
// Build the select query.
$select = $table->getSelectForFindBy();
// Join to the Item table where the collection_id is equal to the ID of our Collection.
if ($collection) {
$table->filterByTagType($select, 'Item');
$select->where('i.collection_id = ?', $collection->id);
}
// Fetch some tags with our select.
$tags = $table->fetchObjects($select);
return $tags;
}