Jump to:

5450 Posts in 1672 Topics by 1197 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Search pagination

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

Page: 1
Go to End
Author Topic: 1060 Views
  • Jona
    Avatar
    Community Member
    19 Posts

    Search pagination Link to this post

    Hi Community,

    I am working with a search function on my SS-powered Web site and am looking for a little guidance. I would like to paginate my search results. Currently, I have the following contents in m Page.php file with contents that I compiled mostly using the helpful documentation.

       function SearchForm(){
       $searchText = isset($this->Query) ? $this->Query : 'Search';
       
       $searchField = new TextField('Search', '', $searchText);
       $searchField->addExtraClass('searchbox');
       $searchField->setTitle('searchbox');
       $fields = new FieldSet($searchField);
           
       $actions = new FieldSet(
        new FormAction('results', 'Go', null, null, 'searchbut', true)
       );
           
       return new SearchForm($this, 'SearchForm', $fields, $actions);
       }
       
    function results($data, $form){
    $data = array(
    'Results' => $form->getResults(),
    'Query' => $form->getSearchQuery(),
    'Title' => 'Search Results'
    );
       
    return $this->customise($data)->renderWith(array('Page_results', 'Page'));
    }

    I have discovered a page in the documentation called "searchcontext," which mentions pagination, but it does not provide an example that extends the code above. Instead, the pagination information reflects a different way of searching. Do I need to learn how to search using the searchcontext, or can I extend the code above somehow? I have tried a few various modifications to both the SS file and the PHP file to no avail.

    Thanks in advance for any insight or help,
    Jona

    1060 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.