Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show in search check for files #92

Merged
merged 13 commits into from
May 2, 2024
Prev Previous commit
Next Next commit
Add DataObject search content controls
  • Loading branch information
amolswnz committed Apr 19, 2024
commit 1f2d6eedec7123222ca3ff5effa90b32c4825f98
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