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?
2 Answers
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.
-
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
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();
}