Skip to content

Commit

Permalink
Merge branch '2' into 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
robbieaverill committed Jul 18, 2018
2 parents 62a2108 + b505f1e commit 7e790d9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
9 changes: 0 additions & 9 deletions CHANGELOG.md

This file was deleted.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[![Build Status](http://img.shields.io/travis/dnadesign/silverstripe-elemental.svg?style=flat)](https://travis-ci.org/dnadesign/silverstripe-elemental)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/dnadesign/silverstripe-elemental/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/dnadesign/silverstripe-elemental/?branch=master)
[![codecov](https://codecov.io/gh/dnadesign/silverstripe-elemental/branch/master/graph/badge.svg)](https://codecov.io/gh/dnadesign/silverstripe-elemental)
[![SilverStripe supported module](https://img.shields.io/badge/silverstripe-supported-0071C4.svg)](https://www.silverstripe.org/software/addons/silverstripe-commercially-supported-module-list/)
[![Version](http://img.shields.io/packagist/v/dnadesign/silverstripe-elemental.svg?style=flat)](https://packagist.org/packages/dnadesign/silverstripe-elemental)
[![License](http://img.shields.io/packagist/l/dnadesign/silverstripe-elemental.svg?style=flat)](LICENSE.md)

Expand Down
9 changes: 9 additions & 0 deletions src/Controllers/ElementSiteTreeFilterSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
use DNADesign\Elemental\Extensions\ElementalPageExtension;
use SilverStripe\CMS\Controllers\CMSSiteTreeFilter_Search;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Core\Config\Config;
use SilverStripe\Forms\DateField;
use SilverStripe\ORM\ArrayList;
use SilverStripe\ORM\DataList;
use SilverStripe\View\SSViewer;

class ElementSiteTreeFilterSearch extends CMSSiteTreeFilter_Search
{
Expand All @@ -30,6 +32,10 @@ protected function applyDefaultFilters($query)
return parent::applyDefaultFilters($query);
}

// Enable frontend themes in order to correctly render the elements as they would be for the frontend
Config::nest();
SSViewer::set_themes(SSViewer::config()->get('themes'));

// 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) {
Expand All @@ -43,6 +49,9 @@ protected function applyDefaultFilters($query)
return (bool) stripos($pageContent, $this->params['Term']) !== false;
});

// Return themes back for the CMS
Config::unnest();

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

0 comments on commit 7e790d9

Please sign in to comment.