F
Filament3w ago
Adel

combine infolist with sub navigation

I have ViewRecord and comined infolists. but i want to divide the view record into multiple pages view (or details), statistics and more. how to have single tabs for them all. my target: is to have single tabs for view, statistics, ...., relation managers
3 Replies
Dennis Koch
Dennis Koch3w ago
You can either combine all on one page or split it up into multiple components and load them in your page. Use content() method on your page and Tabs::make() as a starting point.
Adel
AdelOP3w ago
Thanks for the hint. I ended up overriding the content function
public function content(Schema $schema): Schema
{
return $schema
->components([
Tabs::make('CustomPageTabs')
->tabs([
$this->getOverviewTab(),
$this->getStatisticsTab(),
$this->getTranslationsTab(),
])
->contained(false),
]);
}

protected function getOverviewTab(): Tab
{
return Tab::make(__('Overview'))
->icon(Heroicon::InformationCircle)
->schema([
$this->getInfolistContentComponent(),
]);
}

...


protected function getTranslationsTab(): Tab
{
$hasTranslations = $this->record->translations->count() > 0;

if (! $hasTranslations) {
return Tab::make(__('Translations'))
->icon(Heroicon::Language)
->hidden();
}

return Tab::make(__('Translations'))
->icon(Heroicon::Language)
->badge($this->record->translations->count())
->schema([
$this->getRelationManagersContentComponent(),
]);
}
public function content(Schema $schema): Schema
{
return $schema
->components([
Tabs::make('CustomPageTabs')
->tabs([
$this->getOverviewTab(),
$this->getStatisticsTab(),
$this->getTranslationsTab(),
])
->contained(false),
]);
}

protected function getOverviewTab(): Tab
{
return Tab::make(__('Overview'))
->icon(Heroicon::InformationCircle)
->schema([
$this->getInfolistContentComponent(),
]);
}

...


protected function getTranslationsTab(): Tab
{
$hasTranslations = $this->record->translations->count() > 0;

if (! $hasTranslations) {
return Tab::make(__('Translations'))
->icon(Heroicon::Language)
->hidden();
}

return Tab::make(__('Translations'))
->icon(Heroicon::Language)
->badge($this->record->translations->count())
->schema([
$this->getRelationManagersContentComponent(),
]);
}
Dennis Koch
Dennis Koch3w ago
Great. content() is one of my favorite v4 features. So powerful

Did you find this page helpful?