Importing Filament Custom Pages
I'm building out a custom dashboard and have not been able to include one Filament custom page inside another (using @livewire() or <livewire /> ). It says "unable to find component". Is this expected? I can import other Filament components under the App\Filament namespace, but nothing that lives in Pages. Thanks.
5 Replies
I don't think you can embed a full page inside of another page... can you share some code showing what you're trying to do?
Sure thing. Thanks for the help. So if I mock up a custom "Home" page with another custom "SubSectionOne" page and try to include SubSectionOne inside the blade view for Home, I get the component not found error. If I move SubSectionOne to the parent Filament folder, it works.
This does not work:
but this does:
// sub-section-one.blade.php
This might be an indication that I'm doing something "wrong". Essentially, I have different livewire components I'd like to manage separately on a single dashboard. To keep things organized, I thought I'd create Filament custom pages so they're all in the same folder, instead of spread across Filament and Livewire.
The first screen cap structure is not working (when SubSectionOne is within the Pages folder) but the third screen cap does work (moving it outside Pages).
Hey @the_hgms, thanks for providing more info! So personally, I still think the metal model of a "page within a page" is not quite right, but I think I get what you are trying to do. Basically, this is all for organization, right? If you have reusable "page sections", you want them to live beside the page classes instead of away in the
livewire
folder.
My idea for you is to introduce a "sections" folder instead, so you would have the following structure:
Then, instead of a page, make MySection
a plain Livewire component:
And finally in your AppServiceProvider
, you'll have to register the sections individually:
Let me know if this works for you, I'm using it extensively in my current project.Thanks, @pboivin! This is very nice and I will use this strategy. Really appreciate the feedback. I am able to use the
Sections
components without registering them in the service provider. I think this is because of the livewire config from config/filament.php