Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Empty String in Siteadmin Search

Avatar

Level 1

Hi All,

I am  facing an issue with aem 6.3.

In http://localhost:4502/sites.html/content there is a search icon in the top right corner. If we do an empty search it works fine in local. but in production, it is giving internal server error.

Is there any way to restrict empty search in siteadmin ? Can we customize this search ?

Thanks,

Dipanjan

3 Replies

Avatar

Community Advisor

Hi,

You can add a condition to NOT submit form if input is empty or undefined.

To add condition, you need to update /libs/granite/ui/components/shell/clientlibs/shell/js/omnisearch.js file at line 635, where search overlay is being injected in DOM in openOmnisearch function i.e.

// we load the overlay dynamically

        $.get(url, function(data) {

            $("body").append(data).trigger("foundation-contentloaded");

            omnisearch = document.querySelector(".granite-omnisearch-overlay");

add Check empty input value code after that

// we load the overlay dynamically

        $.get(url, function(data) {

            $("body").append(data).trigger("foundation-contentloaded");

            //check for empty input

            $(".foundation-form.granite-omnisearch-form").submit(function(e){

             var inputField = $(".foundation-form.granite-omnisearch-form input.granite-omnisearch-typeahead-input");

             if(inputField !== typeof undefined){

              if(inputField.val()==="" || inputField.val()===undefined)

                return false;

              }

             });

            omnisearch = document.querySelector(".granite-omnisearch-overlay");

Screen Shot 2018-05-29 at 11.57.36 PM.png

Thanks

Arun



Arun Patidar

Avatar

Level 1

Thanks arunp99088702 for responding.

I have a doubt here, can we create an overlay omnisearch component in our project inside /apps/../ ? Will that work for the siteadmin search ?

Avatar

Community Advisor

Hi,

I doubt, because this is not a component , this is a clientlibs. If you create same file in /app/ folder, this would also be referred.

what you can do, you can create a copy of  /libs/granite/ui/components/shell/clientlibs/shell/js/omnisearch.js file and update js.txt with new file

Thanks

Arun



Arun Patidar