Limit advanced search to specific fields

I have digital archive that is formed solely of legacy academic papers that have been scanned into PDF and arranged into collections, where each collection corresponds to a volume.

Only particular Dublin Core fields are used: Title, Creator, Date, Source. I need to limit the "Narrow by specific fields" dropdown to show only these, but examining the code in search-form.php isn't helping as I can't find any way to limit how the dropdown is constructed.

Is there a way to do this? I'm happy to hack some code

This might be residual tryptophan talking, but here's one approach.

The file that needs to be overridden is application/view/scripts/items/search-form.php. Copy that file into your theme's items folder, so you have {yourtheme}/items/search-form.php.

That dropdown is produced by this code around line 54 in the get_table_options() call

echo $this->formSelect(
                    "advanced[$i][element_id]",
                    @$rows['element_id'],
                    array(
                        'title' => __("Search Field"),
                        'id' => null,
                        'class' => 'advanced-search-element'
                    ),
                    get_table_options('Element', null, array(
                        'record_types' => array('Item', 'All'),
                        'sort' => 'alphaBySet')
                    )
                );

The approach I'm thinking of is to build up what goes in there separately.

So, instead of that function call, build up a $searchElements variable.

echo $this->formSelect(
                    "advanced[$i][element_id]",
                    @$rows['element_id'],
                    array(
                        'title' => __("Search Field"),
                        'id' => null,
                        'class' => 'advanced-search-element'
                    ),
                        $searchElements
                );

To build up that $searchElements variable, above the foreach loop pile on what you need, something like this:

$searchElements = array();
        $titleElement = get_table_options('Element', null, array('element_set_name' => 'Dublin Core', 'element_name' => 'Title'));
        $descriptionElement = get_table_options('Element', null, array('element_set_name' => 'Dublin Core', 'element_name' => 'Description'));
        $searchElements += $titleElement + $descriptionElement;

That's not especially efficient in the multiple calls to the same function that looks stuff up, but seems to basically do the job.

Hope that helps

Hi,

Another solution can be to use the Hide Elements plugin (http://omeka.org/add-ons/plugins/hide-elements).

Sincerely,

Daniel Berthereau
Infodoc & Knowledge management

Well blow me down! I hadn't thought of looking there again. I use it to hide fields on the public pages but never thought it could alter the search criteria as well.

Thank you!