Hi, I'm removing items from a search result using a simple form "SearchForm.php" because i don't want to show files under the "assets/Uploads/" directory. It's deleting correctly. But when the results show up, the page listing number is looking like before removing those unwanted files. So somes result page are showing all 10 results (because all the files are correct) and somes other result page are showing like 6 results (because I delete 4 of them). How can I refresh the page listing with a search results? Thank you in advance!
Here is my code into Page.php under the class "Page_Controller extends ContentController".
function init() {
parent::init();
Requirements::themedCSS("layout");
Requirements::themedCSS("typography");
Requirements::themedCSS("form");
Requirements::themedCSS("styles");
Requirements::themedCSS("navigation");
}
function SearchForm() {
$searchText = isset($this->Query) ? $this->Query : '';
$fields = new FieldSet( new TextField("Search", "", $searchText) );
$actions = new FieldSet( new FormAction('results', '') );
return new SearchForm($this, "SearchForm", $fields, $actions);
}
function results($data, $form) {
$results = $form->getResults();
$arrBadResults = array();
foreach($results as $result) {
$pos = strpos($result->Filename, "/Uploads/");
if($pos >= 0) {
array_push($arrBadResults,$result);
}
}
$cpt=count($arrBadResults)-1;
while ($cpt >= 0){
$results->remove($arrBadResults[$cpt]);
$cpt--;
}
$data = array( 'Results' => $results, 'Query' => $form->getSearchQuery(), 'Title' => 'Résultat de recherche' );
return $this->customise($data)->renderWith(array('Page_results', 'Page', 'HomePage_results', 'HomePage'));
}