Limiting ambuguity in advance search and removing unused DC fieldssearch

Hi All,

Im nearly ready to go live with my install however I have two small issues that are niggling me.

Firstly, it would be great if I could add a drop down to remove ambiguity from advanced search custom fields, i.e. if I could use simple vocal to limit a custom field, then only show those on advanced search, i.e. Limit a custom field called colour to red yellow and blue via simple vocab, then when you click that field in advanced search, have a drop down allowing only the selection of those fields (red yellow and blue).

I dont think this is easily possible however, could someone please clarify?

Secondly, failing the above, is it possible to hide some of the unused default fields from the drop downs on advanced search?
i.e. BCC, Bibliography etc?

I have tried using the,

<?php echo js('jquery'); ?>
<script type="text/javascript" charset="utf-8">
jQuery.noConflict();
jQuery(document).ready(function() {
var blackListElements = new Array();
blackListElements[0] = "Contributor";

for (var i = 0; i < blackListElements.length; i++){
jQuery("#advanced-0-element_id option[label='" +
blackListElements[i] + "']").hide();
}
});
</script>

method at the top of advanced-search.php however there are two issues,

Firstly it doesnt work in I.E. 9 and secondly, for some bizarre reason, it stops my exhibit builder from working (nothing happens when I click the add item button, instead of the items selector popping up) reverting the changes restores functionality.

Any ideas much appreciated, I am really close to going live with this excellent collections platform. If anyone can suggest something please go easy (sorry) Im a bit new to php.

Thanks again and keep up the great work!

The SimpleVocab plugin doesn't currently support altering the advanced search. That feature would likely require some changes to how the advanced search code builds the form, but it is an idea worth pursuing.

The immediate thing I notice about that snippet of JavaScript is that the js('jquery') and jQuery.noConflict() parts shouldn't be needed on any relatively-recent Omeka version, since jQuery is already loaded all the time.

Thanks for the reply,

Understood on the simple vocab point, we would find this particularly useful.

With regards to the second point, would this likely stop the exhibit builder working? Can you think of any reason why it would?

With regards to your comments, could you confirm I should try,

<script type="text/javascript" charset="utf-8">
jQuery(document).ready(function() {
var blackListElements = new Array();
blackListElements[0] = "Contributor";

for (var i = 0; i < blackListElements.length; i++){
jQuery("#advanced-0-element_id option[label='" +
blackListElements[i] + "']").hide();
}
});
</script>

Is there any other wat to acheive this, it may seem pretty irrelevant but our install will have about 25 custom fields, add this to the many built in metadata fields that already exist in the dropdown and its quite a list that is rather unstructured.

Thanks again,

This is the code I would suggest (it's only slightly modified).

<script type="text/javascript">
jQuery(document).ready(function () {
    var blackListElements = [];
    blackListElements[0] = "Contributor";
    jQuery.each(blacklistElements, function () {
        jQuery("#advanced-0-element_id option[label='" + this + "']").hide();
    });
});
</script>

At the moment, JavaScript is probably your best bet for doing this. Given the demand, we may need to think about modifying the advanced search so that elements can be excluded from it more easily (possibly by a plugin).

Thanks for the reply.
I have just had chance to test this however all I get when I do is an empty white screen.

Any ideas?

Any chance you could provide a link?

An issue with that Javascript snippet wouldn't normally cause a blank screen.

You can also try to follow the instructions on retrieving error messages to see if Omeka is encountering any errors when trying to display that page.

Thanks for the reply, unfortunately I cannot yet as the website has not been published (it is on an internal server).

To clarify, if I place the following,

<script type="text/javascript">
jQuery(document).ready(function () {
var blackListElements = [];
blackListElements[0] = "Contributor";
jQuery.each(blacklistElements, function () {
jQuery("#advanced-0-element_id option[label='" + this + "']").hide();
});
});
</script>

<?php
if (!$isPartial):
head(array('title' => 'Advanced Search',
'bodyclass' => 'advanced-search',
'bodyid' => 'advanced-search-page'));

~~~~~~snip~~~~~~~~

Then the "contributor" field is not hidden (it doesnt work)

If I place,

<?php echo js('jquery'); ?>
<script type="text/javascript" charset="utf-8">
jQuery.noConflict();
jQuery(document).ready(function() {
var blackListElements = new Array();
blackListElements[0] = "Contributor";

for (var i = 0; i < blackListElements.length; i++){
jQuery("#advanced-0-element_id option[label='" +
blackListElements[i] + "']").hide();
}
});
</script>

if (!$isPartial):
head(array('title' => 'Advanced Search',
'bodyclass' => 'advanced-search',
'bodyid' => 'advanced-search-page'));

~~~~~~snip~~~~~~~~

It works but breaks the exhibit builder as described (just jumps to the top of the page when you click add item), presumably the add item uses the advanced search page,

If I add,

<?php <script type="text/javascript">
jQuery(document).ready(function () {
var blackListElements = [];
blackListElements[0] = "Contributor";
jQuery.each(blacklistElements, function () {
jQuery("#advanced-0-element_id option[label='" + this + "']").hide();
});
});
</script>?>

<?php
if (!$isPartial):
head(array('title' => 'Advanced Search',
'bodyclass' => 'advanced-search',
'bodyid' => 'advanced-search-page'));

~~~~~~snip~~~~~~~~

I just get a white screen.

No errors seem to be logged when I enable errors.

Sorry for my lack of knowledge, Im new to PHP and thanks again for your help.

You might find some help on this discussion thread: http://omeka.org/forums/topic/customize-advanced-search-1

Your problem seems to be in where you've put your JavaScript.

Where you've placed it, at the very top of the file, is problematic because it comes before the call to head (you can see that call in the bottom part of your snippets). The call to head is what outputs all the HTML that goes at the top of the page, including the header section which loads all the proper scripts.

A better place would be near the bottom of the page. You'll see there's a script tag already there, you can place yours directly after it.

Of your three snippets, you should use the script block from the first one (the one without the PHP and jQuery.noConflict parts). Or, you can use the code I posted in the thread Andy linked to.

Sorry for the delayed reply.

Thank you very much, that worked perfectly!