Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

Empty String in Siteadmin Search

dipanjanc
Level 1
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
Arun_Patidar
Community Advisor
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

dipanjanc
Level 1
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 ?

Arun_Patidar
Community Advisor
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