Skip Navigation

[Resolved] Integrate custom search in second website by jquery/php?

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to show search results from one site in another site.

Solution: Use an iframe with a custom search page from site 1 displayed on site 2.

This support ticket is created 3 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.

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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 4 replies, has 2 voices.

Last updated by a.R 3 years, 8 months ago.

Assisted by: Christian Cox.

Author
Posts
#2035793

a.R

With jQuery+php it´s possible to load the content of a page into a second website.
TOOLSET is also installed on that second website.
Is it somehow possible to make a custom search, contained in this page, also work on the second website?

Maybe copy the view to the second website, integrate the search filter in the page, and load the search results from the first site with jq/php while passing the search parameters to the first site (as URL parameters or so)?

Is it somehow possible to just store the URL a custom search creates (with all URL parameters) into a jQuery-var?

#2036003

Is it somehow possible to make a custom search, contained in this page, also work on the second website?
There's nothing built-in to Toolset that will help you query posts across other sites. I suppose you would have to implement the REST API or something similar to accomplish this with some custom code. An iframe might be easier. On site 1, add the custom search View to a specific page, then use an iframe on site 2 to display that specific page in the iframe. You would have to adjust the links in the custom search View results to trigger an update of the iframe's parent window when the User clicks a link, if you want the User to be redirected back to site 1 in the main window (https://www.wyzant.com/resources/answers/621391/how-to-force-link-from-iframe-to-be-opened-in-the-parent-window).

You could add custom CSS to hide site 1's header, footer, sidebar, etc. from this page in the iframe, and display only the search results. That's probably the most straightforward way to include results from site 1 in site 2.

#2036133

a.R

Yeah, that sounds reasonable.
However - as far as we know, it´s not possible to style an iframe´s content by css.
So how could we do that?

#2036689

However - as far as we know, it´s not possible to style an iframe´s content by css.
Right, that CSS must be applied in site 1, not in site 2. This is why I suggested you create a Page specifically for the custom search shown in the site 2 iframe. If someone is visiting site 1, they should not see links to this custom search page because it will not have the header, footer, sidebars, etc. displayed, and would probably be confusing. Therefore, the custom search page your visitors see on site 1 should be a different page from the custom search page your visitors see in the site 2 iframe (different page, different URLs). You may enqueue a CSS stylesheet specifically for that page in site 1 (something like https://wordpress.stackexchange.com/questions/61244/wp-enqueue-style-on-specific-page-templates), or you may add the CSS code directly to a content template applied only to this search page. I suppose you could create a custom PHP template specifically for the search page, where the site header, footer, sidebars etc. are not included in the output....but that would be tricky so I think a CSS solution will be easier.

#2038411

a.R

My issue is resolved now. Thank you!