Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › trigger search by url not working
- This topic has 7 replies, 2 voices, and was last updated 6 years ago by
Ernest Marcinko.
-
AuthorPosts
-
May 18, 2020 at 2:44 pm #27426
DivineSites
ParticipantHi,
I’m trying to trigger automatic search results by URL
I saw your article about trigger search via an URL but it’s not working for me, it’s just show me the filter
for example: https://www.spectra.co.il/excel-pedia?asp_id=1&asp_s=sumI also want to trigger the auto search by URL only by specifying a specific category and not have to enter the search term itself
is there a way to get the results page with the results of a specific search as a URL and then I can recreate this search by sending the user to that URL
thank you
May 19, 2020 at 2:16 pm #27432Ernest Marcinko
KeymasterHi,
1. The search ID in the URL is not correct. The search shortcode id is 3, not 1. This should work: yoursite.com/excel-pedia?asp_id=3&asp_s=sum
2. This is a bit more complicated, but possibly doable. I am copying an answer from a different thread below, with the istructions. First, you need to navigate to the search results page, as you need the URL for that serach bar.
There is an API call, that can give you the ‘state URL’ of the current search, which is basically what you are looking for. This state URL can be requested via the javascript console.
To get a URL to a specific search state, do the following:
1. Set up the search filters as you need them. In this example I have selected the following filters: https://i.imgur.com/Ki2nv5c.png2. Open your developer console. In Google Chrome browsers you need to hit the F12 button once, and a window will open on the bottom of the browser window. Make sure to navigate to the ‘console’ tab there, it should look like this: https://i.imgur.com/Vzbqsj0.png
3. Now, enter the following code to the console input (I’m assuming the search ID on the results page is still 3):
ASP.api(3, 1, ‘getStateURL’);
..and then hit the enter key to execute it. It should return something like this: https://i.imgur.com/dN5jDJL.png4. That is the state URL of the current search filters and input. You can right click to copy it. Using that URL will open the same exact page with these exact filters selected.
In my case this URL was exactly this.You can use this method to generate any states, then copy the URLs. If you visit these URLs the search is re-created with the filters and the search phrase chosen.
May 20, 2020 at 9:39 am #27444DivineSites
ParticipantHi,
thank you for your quick response.the query in the URL is working for me
but the call to the API function to get the results URL state return false for me
I believe the id of the search results is 3 as you can see in the screenshot: https://i.imgur.com/53u2Od9.pngbut I get false as a response to the API function as you can see in the screenshot: https://i.imgur.com/UGUuqsw.png
what is the meaning of the second parameter of the function is it always 1?May 20, 2020 at 9:55 am #27445Ernest Marcinko
KeymasterHi,
Looks like the instance ID is different. Try this, it should work:
ASP.api(3, 'getStateURL');May 21, 2020 at 9:15 pm #27497DivineSites
Participantthank you ,
it’s returning the url
but the url is not showing me the search resultsscreenshot: https://i.imgur.com/8TlLB5P.png
May 22, 2020 at 7:55 am #27501Ernest Marcinko
KeymasterIndeed.
Can you try adding this string to the end of it:
&asp_s=sum..that should trigger the search for that query.
May 24, 2020 at 10:54 am #27530DivineSites
Participantyes, it’s working
I don’t need the query, I want all the results in a specific category but adding &asp_s at the end gives me all the results as it has an empty queryhere is the script I’m using to get the correct URL:
console.log(ASP.api(3, 'getStateURL')+'&asp_s');thank you for the great support
May 26, 2020 at 7:48 am #27544Ernest Marcinko
KeymasterWell, that would only work if you had a visible category drop-down filter. The “getStateURL” is used to return the current state of the filters.
You could perhaps try to make a category drop down filter, then select the required category, then do the “getStateURL” command. After that, don’t remove the filter from the configuration, but only hide it. Then the filter is still active, but invisible, so entering the URL the filter is still in use. -
AuthorPosts
- The topic ‘trigger search by url not working’ is closed to new replies.