Forum Discussion
Sharepoint search box web part - results only current site
Hi Pieter Veenstra,
Let me see if I understand you correct.
I would need to change the webpart property to : ~site/_layouts/15/osssearchresults.aspx?u={contexturl}path=..
Can you give me some kind of example. As you understand this path= must be something link path=[some variable] to have this a dynamic solution.
Thanks, Mike
Hi Mike,
You can use any page you like. Then within the web part properties of the search boxes configure the url of your custom results page.
The Url I gave you is the out of the box one. Whcih will not work for your requirements as you will need to update the query in the results web part.
You could make the query in the results web part include a querystring parameter.
I would create a page (e.g. pages/results.aspx) then add the results web part on that page.
So in the search box I would configure a url like:
(I've not tested this)
/anysite/Pages/results.aspx?u={contexturl}&mypath=~site
Then in the search results web part you will get a query like:
{searchboxquery} Path:{QueryString.mypath}
- Mike JansenJan 10, 2017Iron Contributor
Pieter Veenstra wrote:Hi Mike,
You can use any page you like. Then within the web part properties of the search boxes configure the url of your custom results page.
The Url I gave you is the out of the box one. Whcih will not work for your requirements as you will need to update the query in the results web part.
You could make the query in the results web part include a querystring parameter.
I would create a page (e.g. pages/results.aspx) then add the results web part on that page.
So in the search box I would configure a url like:
(I've not tested this)
/anysite/Pages/results.aspx?u={contexturl}&mypath=~site
Then in the search results web part you will get a query like:
{searchboxquery} Path:{QueryString.mypath}
Hmmm, have to do some more testing but first test gives the url like this: .......134&mypath=~site&k=test&ql=1043
~site is not changes to the url of the site.
(fyi "test" is my search)
- Jan 10, 2017
You might have to hard code the url in your search boxes.
- Mike JansenJan 10, 2017Iron Contributor
Looks that way. I will try some solutions to see if I can create a more global solution.