0

I am hoping to append 'AND myValue' to the end of all searches which come from the advanced search box webpart. So far I have added a content editor & have been trying to append/alter values on page via jQuery. I have also tried to append k=AND myValue to the url of the page but so far no success. Is there any way to do this without creating a custom solution webpart?

1
  • I don't know your exact scenario, but defining a Search Scope and reconfiguring your advanced search web part might be a possible solution.
    – Markus
    May 20, 2014 at 18:35

2 Answers 2

0

I have also tried to append k=AND myValue to the url of the page

Have you tried using "Value of a parameter from URL" as a Keyword filter in Search Results web part?

Since i cannot comment, i am forced to answer this way. sorry about that.

1
  • No need to be sorry, but if you add details about how to do what you propose this do qualify as an answer :) May 20, 2014 at 16:20
0

I was able to resolve my issue by overriding the preexisting JavaScript function which is responsible for the redirect. The order of events in javascript is as follows

 SearchButtonOnClick() {
     ResetPageHashCode();
     DoAdvancedSearch(.......);
 }
 DoAdvancedSeach(....){
          //A bunch of validation logic & conditions here

          var url = TargetPage+" ?k= "+QueryValue;
          NavigateTo(url);
     }
 }

//ADD FOLLOWING FUNCTION TO CONTENT EDITOR
function navigateTo(url) 
{
   // YOUR CHANGE TO 'url' HERE
   var a = document.createElement('a');
   if(!a.click) 
   { 
      window.location = url;
      return;
   }

   a.setAttribute('href', url);
   a.style.display = 'none';
   document.body.appendChild(a); 
   a.click();
}        

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.