SID-02099: Can I return Twiki search results to another page?
| Status: |
Answered |
TWiki version: |
6.0.1 |
Perl version: |
|
| Category: |
CategorySearch |
Server OS: |
|
Last update: |
10 years ago |
I'm trying to integrate our TWiki with our existing intranet. I can feed a search query to Twiki, and it works great in Twiki. I would like to have those results returned to be displayed with searches of other sources we use. Is there a plugin or an API interface to grab those search results for me to display in a friendlier way?
--
Jerry Beckham - 2015-08-21
Discussion and Answer
There are various ways to achieve this, depending on the depth of integration you want, and on the complexity of implementation you'd accept.
I assume that you are familiar with
search results formatting - if not, then reading this topic is an excellent starter to find out how to display search results in pretty friendly ways.
I'd recommend to proceed like this:
- Create a TWiki topic containing a
SEARCH variable processing exactly the query as you like it. Make use of URLPARAM for all variables you want to pass from your intranet.
- Easiest: Create a form in your intranet with an
action attribute pointing to the TWiki topic view, matching form fields with URLPARAM variables. No integrated search for your intranet and TWiki, though.
- There also a "search" script, see TWiki.TWikiscripts for the CGI parameters it takes. This way you could avoid an extra TWiki topic, but I wouldn't recommend to use it (if only because the documentation is out of synch).
- Needs programming: If you have access to the code processing the search in your intranet, have it issue HTTP GET requests to the TWiki page and merge the results with those from your intranet. You can choose use a "machine readable" format for your formatted search in this case.
- The downside is that doing it in this way, TWiki results are shown with the permissions of your web server.
- Needs programming: Use Javascript to fetch results from both your intranet and TWiki, and merge results on the client side.
- Respects user permissions, but will need to compensate for AJAX access control
in modern browsers. For TWiki, this can be achieved by adding meta http-equiv="Access-Control-Allow-Origin" content="http://your/intranet/portal" to the TWiki topic containing the SEARCH so that pages from your intranet may fetch the TWiki page with Javascript.
- Keeping client side formatting (for search results) and server side formatting (for page layout) in synch can be a nightmare.
--
Harald Jörg - 2015-08-21
Yet another form of integration: Create the search page in TWiki as Harald described, and load that page into an iframe on your intranet. Add a
cover=print URL parameter to the page to remove all the page decoration (header, pulldown menu, navigation links).
--
Peter Thoeny - 2015-08-22
I appreciate your input. I'll explore these options.
--
Jerry Beckham - 2015-08-24
If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.