Skip Navigation

[Resolved] Save the search result along with saved search feature.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 7 replies, has 2 voices.

Last updated by Waqar 1 year, 5 months ago.

Assisted by: Waqar.

Author
Posts
#2625739

jum

Hi,

I designed a Saved search button that stores the search title and search URL.
previous ticket related to this: https://toolset.com/forums/topic/save-users-search-filter/. It works fine

I am searching for an option to store the search result while saving the search so that I can extract the search results post title to the corresponding saved search.

I search for the documentation but I can't find the right one. Please guide me on how to achieve this.

Thanks in advance,

#2625949

Hi,

Thank you for contacting us and I'd be happy to assist.

If you're looking for an autocomplete feature, that shows the options from the already saved searches, that is not available out-of-the-box. It will require a fair amount of code customization.

However, you can use a Toolset view to show the list of already saved searches at the top or at the sidebar, so that visitors can click on them and see the same results, again.

regards,
Waqar

#2626089

jum

Hi Waqar,

Thanks for assisting me,

I need to download the Save Search Result in PDF or Excel. I have a page that lists the saved search title and a link(Search URL) that takes to the search URL and the view will show the search result.

I am working on the possibility of saving the search result post_ title or Post ID along with the Save search URL submit button. So I can list the post that is related to that saved search. I can use this for downloading the saved search.

I have looked into the basic Query URL parameter. But I am not sure how to use this with WP_query to achieve my requirement.
const savedSearchURL = "URL OF THE SAVED SEARCH";

// Extract query parameters into an object
function getQueryParams(url) {
  const params = {};
  const queryString = url.split("?")[1];
  const pairs = queryString.split("&");
  pairs.forEach(pair => {
    const [key, value] = pair.split("=");
    params[key] = decodeURIComponent(value);
  });
  return params;
}

const queryParams = getQueryParams(savedSearchURL);
console.log(queryParams);

I searched the forum but I don't see any resolved solution for this. Can you please provide us guidance/alternatives with the possibility of saving the search result?

#2626161

Thanks for writing back.

If your goal is to track of the 'Save Search' post, you can append it's post ID in the actual saved URL too.

Suppose this is the search URL that is getting saved:

hidden link

After the form has been submitted, you can append that newly created 'Save Search' post's ID in that URL, like this:

hidden link

Where '12345' is the 'Save Search' post's ID. This extra URL parameter will have no impact on the search in the view itself. However, this will allow you to reach to the respective 'Save Search' post, whenever you'll have the search URL.

You can use the hook 'cred_save_data' to execute a custom function that is fired after a new 'Save Search' post has been created through the form.
( ref: https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data )

#2626653

jum

Hi Waqar,

Thanks for the support.

The above mention is to Track the Saved Search Post. My requirement is to show the result of the saved search.

ex: I want to show the search result along with the saved search. This is the output I like to see

Save search title: XXXXX
Save search URL: hidden link
Search result:
Post _Title 1
Post _Title 2
Post _Title 4

Save search title: YYYY
Save search URL: hidden link
Search result:
Post _Title 9
etc..

How to save/show the search results along with the Saved search?
Clicking the Search URL will go to the page and show the search Result but I want to show the post title of the Search result along with the saved search

or Is it possible to export the Search Result in PDF/ CSV?
Thanks in advance

#2627325

Thank you for sharing these details.

What you're planning to achieve is more complicated and can have performance implications if not done right.

I understand you only need to show the 'post titles' of the results, under each saved search. If that's correct, you can follow these steps.

First, you'll have to make sure that on the search results page (where you have the form to save the search), all results are shown at once, without any pagination.

Next, you'll include a multiline textarea field in the form that saves the search. Using some custom script, you can save the post titles of all the search results, in a comma-separated format, in this new field.
( the field itself can be hidden through custom CSS )

This way, all the titles of the results, will be stored with each saved search post. And when showing the list of those saved searches, you can show that list of titles, using a custom shortcode that gets the comma-separated list from the custom field and shows each title with a line break or in the desired format.

#2628597

jum

Hi Waqar,

Thanks for supporting this issue.

I have pagination 10 items per page. Is it possible to have no pagination (all result on one page) only after the search is performed?

#2628727

No, I'm afraid, I can't think of a way to make this work with the pagination enabled at all.

This workaround depends on the availability of all the results/data on the page, all the time.