Moving Sub-Navigation Elements to Main Sidebar as Child Elements
I've been working on integrating a new Relation Page into our project, following the guide in the docs (https://filamentphp.com/docs/3.x/panels/resources/relation-managers#relation-pages).
However, I'm struggling to get the sub-navigation to our standard sidebar instead of in the content pane. I've been using the getRecordSubNavigation() method to generate the navigation items, as shown below:
The
Pages\ManageReviewSites::class
represents our Relation Page. What I'm aiming for is to have this 'sub-navigation' appear in the main sidebar instead when its parent page is accessed.
I've attempted to modify the protected static SubNavigationPosition $subNavigationPosition
, but my only options are top/start/end, nothing that indicates moving it to the main sidebar.
I feel like getRecordSubNavigation() isn't the correct way to accomplish this.
The attached screenshot kind of shows what I'm hoping to accomplish.3 Replies
Solution
Have you try register custom navigation ?
Your are looking for „parent navigation items“
I feel like I'm getting closer. How do I access the record/model in the URL from the custom navigation? My link in this example is
http://foobar.localhost/portal/locations/9c0935b9-6522-456b-9e05-1959a2eca2ab/review-sites
(from the screenshot).
I need to pass the "locations record" to the navigation so it knows which URL to build.
My specific error is: Missing required parameter for [Route: filament.portal.resources.locations.reviewSites] [URI: portal/locations/{record}/review-sites] [Missing parameter: record].
I'm just not sure how to access this from the PanelProivder.
As a side note, I tried making the ManageRelatedRecords use the protected static ?string $navigationParentItem = 'Locations';
without any luck, it is not visible, nor does it throw any errors.
-----
Ok, a little progress, but it feels really wrong.
There has to be a better way.
In particular the hard-coding in visible() and isActiveWhen(). Is there somewhere else I can put this? for example in my relation manager page for example?
Ok, a little more progress:
Registering the custom nav ended up being the path I took. Thank you @Expecto Patronum