On 04/01/2011 03:35 PM, Wouter de Vos wrote:
Hi All,
I am testing around with the Lucene Search, all works well, one problem remains:
I search in Space A. My search results however, are shown in the Main
Wiki Page. This has a different look and feel, and since I do not want
to have confused users, I would like to display the search results in
the same Space as where the User was was in when he-she started the
search. I am guessing its only a one line change in some form, but I
cant seem to find it, I hope someone can help me out..
By default the search feature is implemented as a wiki documents like
all the others, you can edit it, rename it, move it to another space.
This means that all search results are displayed in the same document,
Main.Search, it's not a virtual pseudo-page that works in all spaces.
You could, however, proxy the search from a velocity template applied to
the current space.
You can put this content in a file named "search.vm":
#set ($doc = $xwiki.getDocument('Main.Search'))
#set ($cdoc = $doc)
#set ($tdoc = $doc)
#template('contentview.vm')
You should upload it as an attachment to the current skin document (by
default that's XWiki.DefaultSkin), but if you have more than one skin,
one for each space, you could also put it on the server in
webapps/xwiki/templates
This template allows to display the search results in the URL of another
document.
Then you should edit the file webapps/skins/colibri/global.vm, locate
the search form, and replace the following:
<div id="globallinks">
<form
action="#if($xwiki.exists('Main.Search'))$xwiki.getURL('Main.Search')#else$xwiki.getURL('Main.WebSearch')#end">
<div class="globalsearch">
<label class="hidden" for="headerglobalsearchinput">
==>
<div id="globallinks">
<form action="$doc.getURL()">
<div class="globalsearch">
<input type="hidden" name="viewer"
value="search" />
<label class="hidden" for="headerglobalsearchinput">
The changed file can be uploaded as an attachment to the skin document
as well, or it can be left in place (but leaving it there makes upgrades
harder, since you have to remember to merge this change back when
upgrading).
This change makes searching from the searchbox located in the header to
display results in the current page.
Then you have to edit the Main.LuceneSearch document and replace the
following:
<form action="$doc.getURL('view', 'viewer=search')">
<div class="globalsearch">
<label class="hidden" for="headerglobalsearchinput">
==>
<form action="$doc.getURL('view', 'viewer=search')">
<div class="globalsearch">
<input type="hidden" name="viewer"
value="search" />
<label class="hidden" for="headerglobalsearchinput">
This change makes refining the search terms from the results view
display properly in the same document.
--
Sergiu Dumitriu
http://purl.org/net/sergiu/