Skip to content

Commit

Permalink
Add DataObject search content controls
Browse files Browse the repository at this point in the history
  • Loading branch information
amolswnz committed Apr 17, 2024
1 parent 45b7455 commit 75e2089
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Extensions/SearchServiceExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Exception;
use SilverStripe\Core\Config\Configurable;
use SilverStripe\Core\Injector\Injectable;
use SilverStripe\Forms\CheckboxField;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\ReadonlyField;
use SilverStripe\ORM\DataExtension;
Expand Down Expand Up @@ -36,6 +37,7 @@ class SearchServiceExtension extends DataExtension
use BatchProcessorAware;

private static array $db = [
'ShowInSearch' => 'Boolean',
'SearchIndexed' => 'Datetime',
];

Expand All @@ -59,12 +61,15 @@ public function updateCMSFields(FieldList $fields): void
return;
}

$field = ReadonlyField::create('SearchIndexed', _t(self::class.'.LastIndexed', 'Last indexed in search'));
$showInSearchField = CheckboxField::create("ShowInSearch", _t(self::class . '.ShowInSearch', 'Show in search?'));
$searchIndexedField = ReadonlyField::create('SearchIndexed', _t(self::class . '.LastIndexed', 'Last indexed in search'));

if ($fields->hasTabSet()) {
$fields->addFieldToTab('Root.Main', $field);
$fields->addFieldToTab('Root.Main', $showInSearchField);
$fields->addFieldToTab('Root.Main', $searchIndexedField);
} else {
$fields->push($field);
$fields->push($showInSearchField);
$fields->push($searchIndexedField);
}
}

Expand Down

0 comments on commit 75e2089

Please sign in to comment.