Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

How to refresh the "page listing" with a search results that has been modify?

Go to End



Community Member, 1 Post

6 November 2008 at 8:44am

Edited: 06/11/2008 9:10am

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() {


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) {
		while ($cpt >= 0){
		$data = array( 'Results' => $results, 'Query' => $form->getSearchQuery(), 'Title' => 'Résultat de recherche' );
		return $this->customise($data)->renderWith(array('Page_results', 'Page', 'HomePage_results', 'HomePage'));