Advanced Search

We are using the Thanks Roy theme and OMEKA version 2.2.2. When I am logged in to the Admin site and go to Advanced Search the full search form is displayed along with the Search Items button at the bottom of the form. However, when I am on the public site, a very short form is displayed: Search by Keywords, Narrow by Specific Fields and Search by Collection (we renamed this Search by Section) and the Search Items button is not visible. We would like to have the full form visible except for the obvious Administrative fields. Is this possible? Why are we not seeing the Search Items button (we would also like to rename this Search Records)at the bottom of the form on the Public Site? We are not able to use the Advanced Search because the Search Items button is missing. I can send you screen shots if this will clarify or give you a better idea of the problem. Any help you can provide is much appreciated. Thank you.

That sounds suspiciously like there is some error happening in the form. Try turning on error messages, and see if it gives you some more info about the error.

If the site is public somewhere, a link to it might also help us see what's happening.

Hi Patrick,
Here is the link to the public site:
http://www.oberlinwestwood.org/omeka

Also, I don't see any error messages when I am on the site.
Thank you.

When I go to the public site and click the ... button to the left of the search button, the site loads the the options pictured in the last image on this page http://omeka.org/codex/Managing_Search_Settings_2.0 with the Advanced Search (items only). Clicking the Advanced Search option takes me to a new page which allows me to build a search.

Are you saying that you want those options to load automatically on every page?

No. When I go to Browse Records>Search Records on the Public site I get a short form that's different than when I am logged in to the Admin site. The Search Items button is missing from the Public site therefore I have no way of searching using the form. I have no idea why the form is behaving differently when I am on the Public site.

Thanks...it looks like the search form creation is just stopping after it gets done with the collections list.

Am I guessing right that you made a change to the items/search-form.php file to change the text from "Search by Collection" to "Search by Section"? If so, did you change that in the default views for Omeka in applications/views/scripts, or in the theme's own items/ folder as per this guide?

If it's in the theme's own folder (it probably should be if it isn't), try changing the theme to see if it works as expected. That'll tell us that it's something specific in that file, and we'll probably need to look directly at its code.

Hi Patrick,
Thank you for the suggestion. I will pass it along to our Site administrator and get back to you with the outcome. Thank you again.

Hi Patrick,
Your guess was indeed correct. Our Administrator informed me that the change was made per the guide. I also followed your suggestion and changed the theme from Thanks Roy to Sante fe and the form worked as desired on the Public site. So where do we go from here? Do you need to see the code?
cmrobin

Yeah, next step will definitely be to take a look at exactly what you have in search-form.php

Hello Patrick,
Here is the code:
Please note that more than one file (search-form.php) was changed because the wording changes are across several places.

The following is the code of themes/default/items/search-form.php

Other files that have been changed are themes/default/collection/browse.php
themes/default/items/search.php
themes/default/items/browse.php

"Collections" were replaced with "Sections" , "Items" were replaced with "Records"

<?php
if (!empty($formActionUri)):
$formAttributes['action'] = $formActionUri;
else:
$formAttributes['action'] = url(array('controller'=>'items',
'action'=>'browse'));
endif;
$formAttributes['method'] = 'GET';
?>

<form <?php echo tag_attributes($formAttributes); ?>>
<div id="search-keywords" class="field">
<?php echo $this->formLabel('keyword-search', __('Search for Keywords')); ?>
<div class="inputs">
<?php
echo $this->formText(
'search',
@$_REQUEST['search'],
array('id' => 'keyword-search', 'size' => '40')
);
?>
</div>
</div>
<div id="search-narrow-by-fields" class="field">
<div class="label"><?php echo __('Narrow by Specific Fields'); ?></div>
<div class="inputs">
<?php
// If the form has been submitted, retain the number of search
// fields used and rebuild the form
if (!empty($_GET['advanced'])) {
$search = $_GET['advanced'];
} else {
$search = array(array('field'=>'','type'=>'','value'=>''));
}

//Here is where we actually build the search form
foreach ($search as $i => $rows): ?>
<div class="search-entry">
<?php
//The POST looks like =>
// advanced[0] =>
//[field] = 'description'
//[type] = 'contains'
//[terms] = 'foobar'
//etc
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')
)
);
echo $this->formSelect(
"advanced[$i][type]",
@$rows['type'],
array(
'title' => __("Search Type"),
'id' => null,
'class' => 'advanced-search-type'
),
label_table_options(array(
'contains' => __('contains'),
'does not contain' => __('does not contain'),
'is exactly' => __('is exactly'),
'is empty' => __('is empty'),
'is not empty' => __('is not empty'))
)
);
echo $this->formText(
"advanced[$i][terms]",
@$rows['terms'],
array(
'size' => '20',
'title' => __("Search Terms"),
'id' => null,
'class' => 'advanced-search-terms'
)
);
?>
<button type="button" class="remove_search" disabled="disabled" style="display: none;"><?php echo __('Remove field'); ?></button>
</div>
<?php endforeach; ?>
</div>
<button type="button" class="add_search"><?php echo __('Add a Field'); ?></button>
</div>

<!-- <div id="search-by-range" class="field">
<?php echo $this->formLabel('range', __('Search by a range of ID#s (example: 1-4, 156, 79)')); ?>
<div class="inputs">
<?php
echo $this->formText('range', @$_GET['range'],
array('size' => '40')
);
?>
</div>
</div>-->

<div class="field">
<?php echo $this->formLabel('collection-search', __('Search By Section')); ?>
<div class="inputs">
<?php
echo $this->formSelect(
'collection',
@$_REQUEST['collection'],
array('id' => 'collection-search'),
get_table_options('Collection')
);
?>
</div>
</div>

<!-- <div class="field">
<?php echo $this->formLabel('item-type-search', __('Search By Type')); ?>
<div class="inputs">
<?php
echo $this->formSelect(
'type',
@$_REQUEST['type'],
array('id' => 'item-type-search'),
get_table_options('ItemType')
);
?>
</div>
</div>-->

<!--<?php if(is_allowed('Users', 'browse')): ?>
<div class="field">
<?php
echo $this->formLabel('user-search', __('Search By User'));?>
<div class="inputs">
<?php
echo $this->formSelect(
'user',
@$_REQUEST['user'],
array('id' => 'user-search'),
get_table_options('User')
);
?>
</div>
</div>-->
<?php endif; ?>

<div class="field">
<?php echo $this->formLabel('tag-search', __('Search By Tags')); ?>
<div class="inputs">
<?php
echo $this->formText('tags', @$_REQUEST['tags'],
array('size' => '40', 'id' => 'tag-search')
);
?>
</div>
</div>

<?php if (is_allowed('Items','showNotPublic')): ?>
<div class="field">
<?php echo $this->formLabel('public', __('Public/Non-Public')); ?>
<div class="inputs">
<?php
echo $this->formSelect(
'public',
@$_REQUEST['public'],
array(),
label_table_options(array(
'1' => __('Only Public Items'),
'0' => __('Only Non-Public Items')
))
);
?>
</div>
</div>
<?php endif; ?>

<div class="field">
<?php echo $this->formLabel('featured', __('Featured/Non-Featured')); ?>
<div class="inputs">
<?php
echo $this->formSelect(
'featured',
@$_REQUEST['featured'],
array(),
label_table_options(array(
'1' => __('Only Featured Items'),
'0' => __('Only Non-Featured Items')
))
);
?>
</div>
</div>

<?php fire_plugin_hook('public_items_search', array('view' => $this)); ?>
<div>
<?php if (!isset($buttonText)) $buttonText = __('Search for items'); ?>
<input type="submit" class="submit" name="submit_search" id="submit_search_advanced" value="<?php echo $buttonText ?>">
</div>
</form>

<?php echo js_tag('items-search'); ?>
<script type="text/javascript">
jQuery(document).ready(function () {
Omeka.Search.activateSearchButtons();
});
</script>

Thanks! This was indeed a sneaky one!

The text changes shouldn't make a difference.

What did make a difference is this:

It looks like there was an effort to remove two of the usual search fields, Item Types and Users, from the public search form by commenting them out in the HTML with <!-- code code code -->.

The trouble happened with commenting out the User field. The closing --> came in a little too early.

Currently, it looks like

<!--<?php if(is_allowed('Users', 'browse')): ?>
    <div class="field">
{snipped PHP code}
        </div>
    </div>-->
    <?php endif; ?>

The --> is coming in before the <?php endif; ?>, which breaks it because it doesn't see the starting if.

Just putting the --> after the <?php endif; ?> should fix it.

BTW, that commenting out probably isn't needed, since that field is only shown to people who have permission to search for users -- the general public visiting the site won't see it at all no matter what.

You could also just completely delete the code for displaying fields you don't want, instead of commenting them out. You can always replace them from the original search-form.php file if you need to.

Thank you very much Patrick. I have forwarded your response to our Administrator. I will let you know the outcome once it is corrected.

Thank you again Patrick. The issue is fixed! Your feedback was very instructive and produced the desired results.