Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

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

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

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

Page: 1
Go to End
Author Topic: 501 Views
  • goodjoe696
    Avatar
    Community Member
    1 Post

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

    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'));
       }

    501 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.