protected function applyDefaultFilters($query)
    {
        // If not filtering by a Term then skip this altogether
        if (empty($this->params['Term'])) {
            return parent::applyDefaultFilters($query);
        }

        // Get an array of SiteTree record IDs that match the search term in nested element data
        /** @var ArrayList $siteTrees */
        $siteTrees = $query->filterByCallback(function (SiteTree $siteTree) {
            // Filter by elemental PHP
            if (!$siteTree->hasExtension(ElementalPageExtension::class)) {
                return false;
            }

            // Check whether the search term exists in the nested page content
            $pageContent = $siteTree->getElementsForSearch();
            return (bool) stripos($pageContent, $this->params['Term']) !== false;
        });

        if ($siteTrees->count()) {
            // Apply the list of IDs as an extra filter
            $this->extraTermFilters['ID:ExactMatch'] = $siteTrees->column('ID');
        }

        return $this->applyWithExtraTermFilters($query);
    }
protected function applyDefaultFilters($query)
    {
        // If not filtering by a Term then skip this altogether
        if (empty($this->params['Term'])) {
            return parent::applyDefaultFilters($query);
        }

        // Get an array of SiteTree record IDs that match the search term in nested element data
        /** @var ArrayList $siteTrees */
        $siteTrees = $query->filterByCallback(function (SiteTree $siteTree) {
            // Filter by elemental PHP
            if (!$siteTree->hasExtension(ElementalPageExtension::class)) {
                return false;
            }

            // Check whether the search term exists in the nested page content
            $pageContent = $siteTree->getElementsForSearch();
            return (bool) stripos($pageContent, $this->params['Term']) !== false;
        });

        if ($siteTrees->count()) {
            // Apply the list of IDs as an extra filter
            $this->extraTermFilters['ID:ExactMatch'] = $siteTrees->column('ID');
        }

        return $this->applyWithExtraTermFilters($query);
    }
protected function applyDefaultFilters ( $ query ) { // If not filtering by a Term then skip this altogether if ( empty ( $ this -> params [ 'Term' ] ) ) { return parent :: applyDefaultFilters ( $ query ) ; } // Get an array of SiteTree record IDs that match the search term in nested element data /** @var ArrayList $siteTrees */ $ siteTrees = $ query -> filterByCallback ( function ( SiteTree $ siteTree ) { // Filter by elemental PHP if ( ! $ siteTree -> hasExtension ( ElementalPageExtension :: class ) ) { return false ; } // Check whether the search term exists in the nested page content $ pageContent = $ siteTree -> getElementsForSearch ( ) ; return ( bool ) stripos ( $ pageContent , $ this -> params [ 'Term' ] ) !== false ; } ) ; if ( $ siteTrees -> count ( ) ) { // Apply the list of IDs as an extra filter $ this -> extraTermFilters [ 'ID:ExactMatch' ] = $ siteTrees -> column ( 'ID' ) ; } return $ this -> applyWithExtraTermFilters ( $ query ) ; }
We can't use ORM filtering for PHP methods, so we'll perform our own PHP "search" and get a list of
matching SiteTree record IDs, then add that to the original ORM query.

@param DataList $query Unfiltered query
@return DataList
We can t use ORM filtering for PHP methods so we ll perform our own PHP search and get a list of matching SiteTree record IDs then add that to the original ORM query .