Forum Discussion
Sharepoint search box web part - results only current site
Path:{Site.URL}
- Jan 10, 2017
Hi Brent Ellis,
Does that work?
Isn't Site.Url using the Site of the search results web part? Therefore If all search boxes on many sites all need to lead to the same search results page then that wouldn't work. you would get results from where the search result page has been created.
- Brent EllisJan 10, 2017Silver ContributorAh thx, missed that point, ya, we have always resorted to hard-coding the Paths and -Paths, and using the QueryStrings like Peter mentioned, less trouble than its worth.
- Mike JansenJan 11, 2017Iron Contributor
Part 2 ;-)
Solved it but, a bit strange, I think.
Like mentioned I've changed the results page url like this:
https://mytenant/sites/test/sitePages/results_test.aspx?u={contexturl}&mypath='https://mytenant/sites/test/customer500/case1'
I did not do anything with the "mypath" variable anywhere. Even not in the result source.
I'm not a big fan of solutions that suddenly work, without knowing why ;-)
Can someone explane why this seems to work?
- Mike JansenJan 10, 2017Iron Contributor
Pieter Veenstra wrote:Hi Brent Ellis,
Does that work?
Isn't Site.Url using the Site of the search results web part? Therefore If all search boxes on many sites all need to lead to the same search results page then that wouldn't work. you would get results from where the search result page has been created.
Indeed my experience as well
- Mike JansenJan 10, 2017Iron Contributor
Brent Ellis wrote:
Try adding this to your Change Query option under the properties of the the Search Results Web Part
Path:{Site.URL}I tried that but it takes the url of the page where the search results page is located (the root in my case) not the page where the query was issued.