Delete class and item-sets search fields in the advanced search


#1

Hi,

we need to delete from the public view the fields of search by class and item-sets.
We would like to keep the only field search by value.
We work with Omeka-S 1.4.0 and the theme Center row

What files should we change in Omeka-S to do so ?
Many thanks,
Emilie


#2

Hi. I have created a quick frontend solution to remove fields from items advanced-search, using jQuery. It might be useful to you:

jQuery(document).ready(function($) {
  $("#item-sets").remove();
  $("#resource-class").remove();
});

Run it in console and see if it suits your needs. I have compiled it in a module; I could share it if you wish.

Tassos


#3

Hi, thanks for your reply.

In what file should I write this function ?

many thanks to share your module with me, perhaps is it in github ?

Emilie


#4

Now there is:
https://github.com/kolydart/omeka-hideAdvancedSearchElements


#5

it works ! thanks a lot !


#6

Hi kolydart,

I have spoken too fast. I putyour following code in the query request field of my Advanced-search page, but the item-sets ans resource-class fields are still there

“jQuery(document).ready(function($) {
$(”#item-sets").remove();
$("#resource-class").remove();
});"

Your module is well activated.

Is there another setting I should set up ?
Many thanks,
Emilie


#7

a) check jQuery is running by running the command I sent, in the browser console. Caution: the code you posted contains curly quotes, which will return errors. Here is a quick video.
b) make sure the .js file is accessible (yourdomain.tld/modules/hideAdvancedSearchElements/asset/advanced-search.js). If not, you did not install the module correctly
c) check the source code of the advanced search page and make sure it contains the link to the js file in the section. If not, the specified event listener is not correct. Please note, that the listener I have set is for backend advanced search (yourdomain.tld/admin/item/search).

regards
kolydart


#8

I updated module repository. I attached a listener to frontend advanced search also.


#9

OK, thanks, it works but now on the Site view, all fields have disappeared whereas we need to keep at least the field “research by value” active.

the .js file is well accessible.
I checked the source code on the Site view, here is the mention :

;

I download your new repository with the added mention on the module.ini file : $sharedEventManager->attach(
‘Omeka\Controller\Site\Item’,
‘view.advanced_search’,
array($this, ‘advancedSearch’)
);

Another point :
Sorry for disturbing You because this question is not directly linked to Omeka S but when I have access to the code via the “inspector view” since the web development, how can I save my changes ?
For instance I would like to delete some nodes or rename properties. Since the “inspector view”, I changed those elements but it seems i can not save them.
So that when I go back on the site view, changes have not been taken into account. ==> I precise I tried this option before I downloaded your new repository as now I have no more any fields of research on my page.

Thanks


#10

That is the point of the console. You test your code on the console and when satisfied you store the code in a javascript file which is inserted in the html.
The javascript file to edit is /modules/hideAdvancedSearchElements/asset/advanced-search.js
So:
– comment everything in advanced-search.js except the first & last line (they are used for maximum compatibility)
– run each jQuery command and view the result; for example $("#item-sets").remove();
– when you are satisfied with the result, save the commands in the advanced-search.js file
For more about jQuery selectors, see https://api.jquery.com/category/selectors/