Simple Vocab for Collections

Just a quick question for Omeka 2.0.3 and SimpleVocab 2.0

Should the SimpleVocab plugin work when adding/editing Collections? It doesn't seem to on my installation, though the vocab does show up for adding/editing items.

If this is normal, would it be difficult to enable this?

Yes, that's to be expected -- we updated the plugin to be compatible with Omeka 2.0, but haven't yet updated it to address the new functionality of Collections also having Dublin Core data.

The introduction of things besides Items having DC raises the question of whether the options for each element should be different according to record type (Item vs. Collection). That's a question we haven't tackled yet, as we're trying to get basic updates to plugins out the door.

That said, I _think_ that the following changes would let you have the same controlled vocab for each element on both Items and Collections. Keep in mind that these will affect both Item and Collection editing, with exactly the same options for both.

In the plugin's folder, go to libraries/SimpleVocab/Controller/Plugin/SelectFilter.php

Around line 22, alter $_defaultRoutes so it looks like this:

protected $_defaultRoutes = array(
        array('module' => 'default', 'controller' => 'items',
              'actions' => array('add', 'edit', 'change-type')),
        array('module' => 'default', 'controller' => 'collections',
                'actions' => array('add', 'edit')),
        array('module' => 'default', 'controller' => 'elements',
              'actions' => array('element-form')),

In the same file, around line 70, there is a block of code to do a foreach loop. Alter it so it looks like:

foreach ($this->_simpleVocabTerms as $element_id => $terms) {
   $element = $db->getTable('Element')->find($element_id);
   $elementSet = $db->getTable('ElementSet')->find($element->element_set_id);
   add_filter(array('ElementInput', 'Item', $elementSet->name, $element->name),
        array($this, 'filterElementInput'));
   add_filter(array('ElementInput', 'Collection', $elementSet->name, $element->name),
        array($this, 'filterElementInput'));

I've only done the most basic testing, but so far that looks like it does the trick.

Thanks for the help. I tried the changes and it disabled SimpleVocab for items as well as collections. Are their other changes to other code or the db maybe?

As for the issue of overlapping DC elements for items and collections, I'd think the best course would be that they are kept as distinct as possible, with different Vocab, different comments, and so on. But I had already realized they would be treated the same for now, so I can work around it I'm fairly certain. I don't plan to use all the extended elements and may add a few of my own.

A followup:

I changed your second code segment back to including the original foreach loop and $element and it works for both items and collections. That is:

foreach ($simpleVocabTerms as $simpleVocabTerm) {
$element = $db->getTable('Element')->find($simpleVocabTerm->element_id);
$elementSet = $db->getTable('ElementSet')->find($element->element_set_id);
add_filter(array('ElementInput', 'Item', $elementSet->name, $element->name),
array($this, 'filterElementInput'));
add_filter(array('ElementInput', 'Collection', $elementSet->name, $element->name),
array($this, 'filterElementInput'));

As well, I'd suggest that the Hide Elements plugin also distinguish between items and collections. Though I guess that's not an Omeka plugin but a community contribution.

I can see that a distinction between different types could be useful for Hide Elements, but I'm having a little trouble thinking of an interface for that which wouldn't be totally bonkers.

Hide Elements is already a somewhat imposing field of checkboxes; I'm not sure where I could add options for hiding from All/Items/Files/Collections or a combination thereof.