Hiya... I'm doing a rebrand of an existing SS site, I've run into a problem with the search form. It had been set up straight out of the tutorial. I've needed to do a hand-written the form in the template (basing it on what SS was originally doing as much as possible). It produces the initial results page okay, but it's not passing the search vars as GETs on to the next/prev and page links and I can't see why. I'm not well-versed enough in the ways of the sapphire codebase to see exactly how or where they get added.
I had to add $form = $this->SearchForm() in my results() because the $form arg was being passed null, which might explain my troubles - but I can't work out why it is null.
Here's the relevant bit of my PageController (the extra gumf is for doing 11-20 of 88 results):
function SearchForm() {
$searchText = isset($this->Query) ? $this->Query : '';
$fields = new FieldSet(
new TextField("Search", "", $searchText)
);
$actions = new FieldSet(
new FormAction('results', 'Search', 'Search', 'btn_search')
);
return new SearchForm($this, "Search", $fields, $actions);
}
function results($data, $form){
$showPerPage = 10;
$form = $this->SearchForm();
$results = $form->getResults($showPerPage);
$firstItemIndex = ($showPerPage * ($results->CurrentPage() - 1)) + 1;
$data = array(
'Results' => $results,
'Query' => $form->getSearchQuery(),
'Title' => 'Search Results',
'FirstItemIndex' => $firstItemIndex,
'LastItemIndex' => $firstItemIndex + $showPerPage - 1,
'ShowPerPage' => $showPerPage,
);
return $this->customise($data)->renderWith(array('Page_results', 'Page'));
}
And the search form looks like:
<form method="post" action="/home/results" name="Search">
<fieldset class="search">
<label for="searchfield">Search the site:</label>
<input type="text" class="searchfield" id="searchfield" value="" name="Search" size="16" maxlength="100">
<input type="submit" class="btn_search" title="Search" name="SearchBtn" value="Search" >
</fieldset>
</form>