Disable sub-navigation on specify page
Hello, is it possible to disable the sub-navigation resource on certain pages only?
I have a resource that has a public function getRecordSubNavigation, but I want to hide it on a specific page of type ViewRecord.
This page is not included in the menu, but I want to disable this menu for this page.
Is it possible ?
7 Replies
Can you post your getRecordSubNavigation code?
Does inspecting the properties of the
Page $page
parameter allow you to conditionally change the values?
On my ServerResource.
As you see, there is no ViewProvisioningServer page. But on this page, the sub-navigation appears, which seems to be normal, but I would like to deactivate it right here.
and if you dd($page) what do you get? I wonder if there's a property in there that could be used to exclude certain things?
Or is there something in your ViewProvisioningServer class that can control when it's registered?
ViewRecord
has a parent shouldRegisterNavigation()
which can be overridden.I tried with shouldRegisterNavigation() set to false in ViewProvisioningServer but the sub-navigation still appears. I think shouldRegisterNavigation() is just to display ViewProvisioningServer in the menu, but not to remove the menu itself.
I haven't seen anything that could help me in dd($page)
Solution
Ok, I have the solution.
In the ViewRecord page, add this:
thank you @DrByte for your time
Yay! Glad you found it. I've done a lot of code-diving to find answers to similar questions: just keep following the features of the parent classes, and you can discover a lot of cool things!