CaseStudy.php

1
2
3
4
5
...
public static $indexes = array( 
    "fulltext (Title, Content)"
);
...

Page.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
class Page_Controller extends ContentController {
...
    public function results($data, $form){
        $data = $_REQUEST; 
        
        $query = htmlspecialchars($data['Search'], ENT_QUOTES,'UTF-8'); 
        
        $pages = DataObject::get("SiteTree","MATCH (Title,Content) AGAINST ('$query' IN BOOLEAN MODE)");
        $studies = DataObject::get("CaseStudy","MATCH (Title,Content) AGAINST ('$query' IN BOOLEAN MODE)");
        
        $searchresults = new DataObjectSet();
        $searchresults->merge($pages);
        $searchresults->merge($studies);
        
        if($searchresults){ 
            $data['Results'] = $searchresults;           
        } else { 
            $data['Results'] = ''; 
        } 
        
        $data['Title'] = 'Search Results'; 

        return $this->customise($data)->renderWith(array('Search_results','Page')); 
    }
...
}