Here's some example code for how to get the item types of the items in
a particular collection. (I was going to add it to the forums only,
but the backticks formatting was screwy, and I thought that you might
be interested)
<?php
function get_item_types_for_collection($collection) {
$db = get_db();
$itemTableName = $db->Item;
$itemTypeTableName = $db->ItemType;
$stmt = $db->query("SELECT DISTINCT `it`.`item_type_id` FROM `
$itemTableName` AS `it`, `$itemTypeTableName` AS `itt`
WHERE `it`.`collection_id` = ? AND
`it`.`item_type_id` = `itt`.`id`
ORDER BY `itt`.`name` ASC",
array($collection->id));
$results = $stmt->fetchAll();
$itemTypes = array();
$itemTypeTable = $db->getTable('ItemType');
foreach($results as $result) {
$itemTypeId = $result['item_type_id'];
if ($itemTypeId) {
$itemTypes[] = $itemTypeTable->find($itemTypeId);
}
}
return $itemTypes;
}
?>
<?php head(array('title'=>'Browse
Collections','bodyid'=>'collections','bodyclass' => 'browse')); ?>
<div id="primary">
<h1>Collections</h1>
<div class="pagination"><?php echo pagination_links(); ?></div>
<?php while (loop_collections()): ?>
<div class="collection">
<h2><?php echo link_to_collection(); ?></h2>
<h3>Item Types</h3>
<?php
$collection = get_current_collection();
$itemTypes = get_item_types_for_collection($collection);
foreach($itemTypes as $itemType) {
echo '<p>' . html_escape($itemType->name) . '</p>';
}
?>
<div class="element">
<h3>Description</h3>
<div class="element-text"><?php echo
nls2p(collection('Description', array('snippet'=>150))); ?></div>
</div>
<div class="element">
<h3>Collector(s)</h3>
<?php if(collection_has_collectors()): ?>
<div class="element-text">
<p><?php echo collection('Collectors',
array('delimiter'=>', ')); ?></p>
</div>
<?php endif; ?>
</div>
<p class="view-items-link"><?php echo
link_to_browse_items('View the items in ' . collection('Name'),
array('collection' => collection('id'))); ?></p>
<?php echo plugin_append_to_collections_browse_each(); ?>
</div><!-- end class="collection" -->
<?php endwhile; ?>
<?php echo plugin_append_to_collections_browse(); ?>
</div><!-- end primary -->
<?php foot(); ?>