F
Filamentβ€’12mo ago
myster

Sub navigation

How to use Sub navigation? Is it already available?
58 Replies
einnlleinhatt_
einnlleinhatt_β€’12mo ago
$navigationParentItems
Flo
Floβ€’12mo ago
Hello, I manage to add a custom page to the sub navigation by adding $navigationParentItems to the class of my Custom page. On the other hand, when I go to the view of this Custom page, the sub navigation does not appear. I hope to have been clear. Do you know how to customize the view for this?
Prodex
Prodexβ€’12mo ago
I'm confused as well. The sub navigation is not showing, and the docs are quite short for that topic...
Flo
Floβ€’12mo ago
Currently the sub navigation is displayed if custom pages extends "ManageRelatedRecords" but not for "Page"
BlackShadow
BlackShadowβ€’12mo ago
Im a little confused too, i added the following to my resource (basically copied the demo) but no nav is appearing.
public static function getRecordSubNavigation(Page $page): array
{
return $page->generateNavigationItems([
Pages\EditProfile::class,
Pages\ViewProfile::class,
ManageProfileAddresses::class,
]);
}
public static function getRecordSubNavigation(Page $page): array
{
return $page->generateNavigationItems([
Pages\EditProfile::class,
Pages\ViewProfile::class,
ManageProfileAddresses::class,
]);
}
Prodex
Prodexβ€’12mo ago
yes, same for me and "ManageRelatedRecords" doesn't make sense for me, as I want to add custom pages as well.
BlackShadow
BlackShadowβ€’12mo ago
Im not really using custom pages, just the normal view, edit and the new ManageRelatedRecords
Prodex
Prodexβ€’12mo ago
can anyone from the core team give us a hint?
Flo
Floβ€’12mo ago
@Prodex Does this appear for you on pages that have "ManageRelatedRecords"?
BlackShadow
BlackShadowβ€’12mo ago
Maybe we need to enable it first?
Prodex
Prodexβ€’12mo ago
the docs don't say anything about that
Dennis Koch
Dennis Kochβ€’12mo ago
@Dan Harrin Can you shed some light? There are multiple confused people here πŸ˜…
Dan Harrin
Dan Harrinβ€’12mo ago
sub navigation is not parent items someone tell me what youre trying to do
BlackShadow
BlackShadowβ€’12mo ago
Added this to my ProfileResource added a new ManageProfileAddresses page.
Flo
Floβ€’12mo ago
add sub navigation to Custom Page
Dan Harrin
Dan Harrinβ€’12mo ago
not specific enough please explain what youre actually trying to achieve
BlackShadow
BlackShadowβ€’12mo ago
My issue: Display the sub navigation
Dan Harrin
Dan Harrinβ€’12mo ago
the demo even has an example in the post resource
BlackShadow
BlackShadowβ€’12mo ago
I copied this, seems like im missing something still. πŸ€”
Dan Harrin
Dan Harrinβ€’12mo ago
so what is happening
Flo
Floβ€’12mo ago
class LogServer extends Page
{

protected static string $resource = ServerResource::class;

protected static string $view = 'filament.resources.server-resource.pages.log-server';

protected static ?string $title = 'Logs';

protected static ?string $navigationIcon = 'heroicon-s-book-open';

public Server $record;
}
class LogServer extends Page
{

protected static string $resource = ServerResource::class;

protected static string $view = 'filament.resources.server-resource.pages.log-server';

protected static ?string $title = 'Logs';

protected static ?string $navigationIcon = 'heroicon-s-book-open';

public Server $record;
}
Should I do something else? Configure the view?
BlackShadow
BlackShadowβ€’12mo ago
Nothing πŸ˜†
Dan Harrin
Dan Harrinβ€’12mo ago
have you defined getRecordSubNavigation() in the resource
BlackShadow
BlackShadowβ€’12mo ago
I think we are talking about 2 different issues here tbh.
Dan Harrin
Dan Harrinβ€’12mo ago
definitely.
BlackShadow
BlackShadowβ€’12mo ago
Yes.
Flo
Floβ€’12mo ago
yes :
public static function getRecordSubNavigation(Page $page): array
{
return $page->generateNavigationItems([
Pages\ListSitesServer::class,

Pages\LogServer::class,

]);
}
public static function getRecordSubNavigation(Page $page): array
{
return $page->generateNavigationItems([
Pages\ListSitesServer::class,

Pages\LogServer::class,

]);
}
Dan Harrin
Dan Harrinβ€’12mo ago
show the code for these pages
BlackShadow
BlackShadowβ€’12mo ago
I will let him go first, it will probably solve my issue too.
Dennis Koch
Dennis Kochβ€’12mo ago
One he posted above
Prodex
Prodexβ€’12mo ago
Like Flo said, I also copied the example from the docs and implemented my pages. But the sub nav doesn't show up, and we're trying to figure out why.
public static function getRecordSubNavigation(Page $page): array
{
return $page->generateNavigationItems([
Pages\Overview::class,
Pages\Projects::class,
]);
}
public static function getRecordSubNavigation(Page $page): array
{
return $page->generateNavigationItems([
Pages\Overview::class,
Pages\Projects::class,
]);
}
Is there anything, that needs to be done for the sub navigation to show up? (it's in the resource class btw, just like the docs said)
Dennis Koch
Dennis Kochβ€’12mo ago
Wait is it a resource or a custom page you put this on? Dan, do we support custom pages with subnavigation?
Dan Harrin
Dan Harrinβ€’12mo ago
all pages support sub navigation
Flo
Floβ€’12mo ago
(For me, it appears well on classic "view, edit..." pages but not on custom pages, and I think it's because of my view. But what to add there?)
Dan Harrin
Dan Harrinβ€’12mo ago
do any of you have custom themes maybe they need recompiling
BlackShadow
BlackShadowβ€’12mo ago
omg.. Thats it.. That solves my problem atleast....
Dan Harrin
Dan Harrinβ€’12mo ago
please recompile themes after every update
Dennis Koch
Dennis Kochβ€’12mo ago
Best to add this to composer scripts, too.
BlackShadow
BlackShadowβ€’12mo ago
Gonna do that right now πŸ‘€
Flo
Floβ€’12mo ago
For me, it still doesn't work. Should I add something here? log-server.blade.php
<x-filament-panels::page>

</x-filament-panels::page>
<x-filament-panels::page>

</x-filament-panels::page>
What exactly did you do? I use "npm run dev" in the background.
BlackShadow
BlackShadowβ€’12mo ago
I ran npm run build Refreshed the page and just like magic, it appeared!
Dennis Koch
Dennis Kochβ€’12mo ago
Yeah, probably something different here, as it works on the Resource.
Flo
Floβ€’12mo ago
Yes, anything that extends from "ManageRelatedRecords", "EditRecord", "ListRecords", "ViewRecord" works, but not if it extends from "Page" but why ?
Dan Harrin
Dan Harrinβ€’12mo ago
on the custom page
/**
* @return array<string, mixed>
*/
public function getSubNavigationParameters(): array
{
return [
'record' => $this->getRecord(),
];
}

public function getSubNavigation(): array
{
return static::getResource()::getRecordSubNavigation($this);
}
/**
* @return array<string, mixed>
*/
public function getSubNavigationParameters(): array
{
return [
'record' => $this->getRecord(),
];
}

public function getSubNavigation(): array
{
return static::getResource()::getRecordSubNavigation($this);
}
ListRecords doesnt do it, its just β€œrecord” pages just like default custom pages dont have a $record, they dont have record sub navigation either so you just have to point it towards the resource yourself
Prodex
Prodexβ€’12mo ago
yeah! That's it for me. Maybe this needs to be in the docs as well in the page section? I can add that later if you want.
Dan Harrin
Dan Harrinβ€’12mo ago
realised that using records on custom pages was severely underdocumented and also improved the experience of using InteractsWithRecord to handle the subnav you shouldnt need to define getSubNavigation() etc when this is released
Dennis Koch
Dennis Kochβ€’12mo ago
Damn, that was fast πŸ˜…
Dan Harrin
Dan Harrinβ€’12mo ago
just released v3.1.2 unofficially for this, since it should be a big improvement will be on packagist in 2 mins
Prodex
Prodexβ€’12mo ago
Nice!! Thank you so much Dan for your great effort all the time ❀️
Flo
Floβ€’12mo ago
Thank you Dan !
Moolchand Sharma
Moolchand Sharmaβ€’12mo ago
I'm using filament 3.1.8, and i have implemented everything written on the docs but not working. Could someone please help me Thanks
No description
hichem8377
hichem8377β€’12mo ago
protected static ?string $navigationParentItem = 'Hearing settings'; return Call to a member function keyBy() on null Please any one got the same issue
DrByte
DrByteβ€’12mo ago
Probably need to upgrade your Filament version.
ahinkle
ahinkleβ€’11mo ago
I ran into this. You may have permission mismatch here where the user can't access the parent item - but does have access to the child.
nostrodamned
nostrodamnedβ€’10mo ago
Hi I tried this on a custom page - with and without commented code? https://gist.github.com/craigvc/f550679a599fd4dbb2721f24a50fbd7f I just want the navigation items to show up under settings - is this possible>?
Gist
Settings.php
GitHub Gist: instantly share code, notes, and snippets.
Dan Harrin
Dan Harrinβ€’10mo ago
clusters are superior to nav parent items, try those
nostrodamned
nostrodamnedβ€’10mo ago
Hi yes ended up using them thanks!!!!
Want results from more Discord servers?
Add your server