Record pages in a sidebar

A client opens with pages in a sidebar, a header with key figures, a logo and a searchable switcher to the other clients.

The code

app/src/Controllers/ClientController.php – defineRecordPages() with a switcher whole file
protected function defineRecordPages(DataObject $record): ?RecordPages
{
return RecordPages::create()
->page(RecordPage::create('overview', 'Overview')->groups(['basics', 'address']))
->page(RecordPage::create('contacts', 'Contacts')->sublist(ContactSubController::class))
->page(RecordPage::create('notes', 'Notes')->groups(['notes']))
->separator()
->switcher($this->clientSwitcher($record));
}

/**
* All clients, searchable, each linking to the page that is open.
*/
private function clientSwitcher(DataObject $record): RecordSwitcher
{
$segment = (string) $this->getRequest()->param('OtherID');
$switcher = RecordSwitcher::create()->searchable();
foreach (Client::get()->sort('Name') as $client) {
$switcher->option(
(string) $client->Name,
$this->Link('view/' . $client->ID . ($segment !== '' ? '/' . $segment : '')),
$client->ID === $record->ID
);
}
return $switcher;
}

protected function defineHeaderFields(DataObject $record): ?ArrayList
{
/** @var Client $record */
return ArrayList::create([
ArrayData::create([
'Label' => 'Industry',
'Value' => $record->Industry()->exists() ? $record->Industry()->getFullTitle() : '–',
]),
ArrayData::create(['Label' => 'Projects', 'Value' => (string) $record->Projects()->count()]),
]);
}

protected function defineRecordImage(DataObject $record): ?string
{
return RecordFiles::fileOf($record, 'Logo') ? $this->Link('file/' . $record->ID . '/Logo') : null;
}