How do I modify the plugin's view page?

Is there a command that would "export" the blade files and put it in my Laravel views (or some other) folder of a Filament plugin and then I could modify it? The plugin author doesn't speak about it on the docs. But perhaps that is something that the view files export for further design tweaking is a "common knowledge" among the Filament users? I am new to Filament and the docs are kind of huge, so perhaps I have missed something?
Solution:
change it to <x-filament-impersonate::banner />...
Jump to solution
59 Replies
LeandroFerreira
LeandroFerreira6mo ago
what plugin?
Alfatic
Alfatic6mo ago
@Leandro Ferreira Multiple in fact. Isn't that possible? Do I need to manually fork a git project and do my own version all the time? I just want to change some visual stuff in the presentable layer in the blade file of some plugins. Is there some universal command to export that view folder to my Larvel project? Right now it's all in vendors folder. However, when I composer upgrade the changes will be gone. If it's not possible I will have to fork the github projects I want to change I guess.
LeandroFerreira
LeandroFerreira6mo ago
you should publish views by plugin I think you can also fork and change what you want If you need to change css, you can use a custom theme https://filamentphp.com/docs/3.x/panels/themes#creating-a-custom-theme
Alfatic
Alfatic6mo ago
you should publish views by plugin I think
@Leandro Ferreira How to do that?
LeandroFerreira
LeandroFerreira6mo ago
check the plugin page if it is available
Alfatic
Alfatic6mo ago
What should I type in the terminal? Is there an artisan command for that type of export? something like php artisan export:filement-view thenameoftheplugin
LeandroFerreira
LeandroFerreira6mo ago
you should check in the plugin page For example, I have a plugin https://filamentphp.com/plugins/leandrocfe-apex-charts#installation You can publish the views using the command php artisan vendor:publish --tag="filament-apex-charts-views"
Filament
Apex Charts by Leandro Ferreira - Filament
Apex Charts integration for Filament.
Alfatic
Alfatic6mo ago
Thanks, is this universal or the plugin creator have to support this somehow?
LeandroFerreira
LeandroFerreira6mo ago
plugin creator
Alfatic
Alfatic6mo ago
Can I just manually copy those files somewhere in my project? Is there some location where Laravel looks for this automatically and will prefer files from there instead of files from the plugin?
LeandroFerreira
LeandroFerreira6mo ago
should work in the resources/views/vendor I think
Alfatic
Alfatic6mo ago
can i just copy the resources folder with lang and views folders and files somewhre Oko i will try manually copy it there @Leandro Ferreira it's not working How would you do it yourself with e.g. Filament Impersonate
Alfatic
Alfatic6mo ago
@Leandro Ferreira Let's say you want to add some other stuff in the top banner and some other logic For that I need to somehow export/put the blade view file in my Laravel project (not sure where exectly and under which folder?) And then make Laravel and Filament/Filament Impersonate to take my new blade file instead of that file in the original /vendor folder where all plugins and packages of composer are stored. How would you do that? Also, there in the project github I see also lang folder which would be handy to be able to export and change as well. Here it is:
Alfatic
Alfatic6mo ago
GitHub
filament-impersonate/resources at master · stechstudio/filament-imp...
Filament plugin that makes it easy to impersonate your users - stechstudio/filament-impersonate
Alfatic
Alfatic6mo ago
I will appreciate any help Leonardo.
LeandroFerreira
LeandroFerreira6mo ago
create this file resources/views/vendor/filament-impersonate/components/banner.blade.php Copy/paste the original content and edit what you want
Alfatic
Alfatic6mo ago
Thanks, it's insane. I can add stuff to above but this part here:
<div id="impersonate-banner">
<div>
{{ __('filament-impersonate::banner.impersonating') }} <strong>{{ $display }}</strong>
</div>

<a href="{{ route('filament-impersonate.leave') }}">{{ __('filament-impersonate::banner.leave') }}</a>
</div>
<div id="impersonate-banner">
<div>
{{ __('filament-impersonate::banner.impersonating') }} <strong>{{ $display }}</strong>
</div>

<a href="{{ route('filament-impersonate.leave') }}">{{ __('filament-impersonate::banner.leave') }}</a>
</div>
if I try:
<div id="impersonate-banner">
HELLO
</div>
<div id="impersonate-banner">
HELLO
</div>
it's not showing.
Impersonating user Admin [Leave]
Impersonating user Admin [Leave]
But this:
@props(['style', 'display', 'fixed', 'position'])
<div>Showing when not impersonating</div>
@if(app('impersonate')->isImpersonating())
@props(['style', 'display', 'fixed', 'position'])
<div>Showing when not impersonating</div>
@if(app('impersonate')->isImpersonating())
works, and I see the div on every page when I am not impersonating. Any idea why it's not taking the if condition content into account? But at least I know it kind of knows about this file. So, thanks for showing me how to do that. I will try that for languages in similar fashion now. Hmm, so the langs are working. Meaning if I copy the banner.php file to /lang/vendor/filament-impersonate/en/banner.php and change the text there it works. The question is why can't I change the code and why it's ignoring the if code altogether. Because I can delete the whole id=impersonate-banner div and it will still show up on the page. Could this be the culprit:
public function bootingPackage(): void
{
FilamentView::registerRenderHook(
'panels::body.start',
static fn (): string => Blade::render("<x-filament-impersonate::banner/>")
);

// For backwards compatibility we're going to load our views into the namespace we used to use as well.
$this->loadViewsFrom(__DIR__.'/../resources/views', 'impersonate');

// Alias our table action for backwards compatibility.
// STS\FilamentImpersonate\Impersonate is where that class used to exist, and I don't
// want a breaking release yet.
if (!class_exists(\STS\FilamentImpersonate\Impersonate::class)) {
class_alias(Impersonate::class, \STS\FilamentImpersonate\Impersonate::class);
}
}
public function bootingPackage(): void
{
FilamentView::registerRenderHook(
'panels::body.start',
static fn (): string => Blade::render("<x-filament-impersonate::banner/>")
);

// For backwards compatibility we're going to load our views into the namespace we used to use as well.
$this->loadViewsFrom(__DIR__.'/../resources/views', 'impersonate');

// Alias our table action for backwards compatibility.
// STS\FilamentImpersonate\Impersonate is where that class used to exist, and I don't
// want a breaking release yet.
if (!class_exists(\STS\FilamentImpersonate\Impersonate::class)) {
class_alias(Impersonate::class, \STS\FilamentImpersonate\Impersonate::class);
}
}
LeandroFerreira
LeandroFerreira6mo ago
I think you have a way to do it now Maybe you can check this on the plugin channel #impersonate
Alfatic
Alfatic6mo ago
I have asked there but it's empty there. It's weird because I see this in debugbar
Alfatic
Alfatic6mo ago
No description
Alfatic
Alfatic6mo ago
As you can see it's still pulling the data from the original composer location But when I stop impersonating I click on leave, well, in my case Woop!!! I see this
Alfatic
Alfatic6mo ago
No description
Alfatic
Alfatic6mo ago
and this banner.blade.php file is the one I copied from composer original location into: /resources/views/vendor/filament-impersonate/components/banner.blade.php it is not the file from: vendor/stechstudio/filament-impersonate/resources/views/components/banner.blade.php How is that possible? When being impersonated it is not loading my custom file. And when it is NOT impersonated it is loading my custom file. That doesn't make sense. It should load the file all the time, right? --- I can change the impersonate div content directly in the vendor composer folder. But that's not a good solution. Can you gives help why it's not working normally? Why do I have to edit it manually in the composer vendor folder? So, I somehow need to force Filament Impersonate to always render /resources/views/vendor/filament-impersonate/components/banner.blade.php and never vendor/stechstudio/filament-impersonate/resources/views/components/banner.blade.php Because for when not impersonating it renders the correct one:
Alfatic
Alfatic6mo ago
No description
Alfatic
Alfatic6mo ago
But when impersonating it take the incorrect one:
Alfatic
Alfatic6mo ago
No description
Alfatic
Alfatic6mo ago
It should also be /resources/views/vendor/filament-impersonate/components/banner.blade.php But instead it is loading the composer vendor folder file: vendor/stechstudio/filament-impersonate/resources/views/components/banner.blade.php I don't understand why such switching occurs? it doesn't make any sense, does it?
Andrew Wallo
Andrew Wallo6mo ago
Just type in the console “php artisan vendor:publish” and you will see a list of all package views you can publish
Alfatic
Alfatic6mo ago
I did php artisan vendor:publish --tag="filament-impersonate-views" but all it did was copied the icon additionaly. The problem is not the view itself, but the fact that only in the state of being NOT impersonating it's loading this vendor-published view when being IN the state of impersonating it is loading the vendor/stechstudion/... path @Andrew Wallo Take a look at the last two images I have posted. The different path for the blade view component is being shown in the debugbar. The first "aaa" screenshot is correct. It's loading my customized vendor-published view, as it should. But the second screenshot with the black top banner is not loading the vendor-published view. It's loading the vendor-original view from the composer folder. I have no idea what is causing such weird behavior. Any idea what is causing this "switching" behavior? I don't see anything of such nature here:
Alfatic
Alfatic6mo ago
No description
Alfatic
Alfatic6mo ago
But if I directly change it in the composer vendor folder like this:
Andrew Wallo
Andrew Wallo6mo ago
No dont don’t do that. Do you need to change the logic of the view or just the styling/css? Also so is your custom styling in the view being loaded or no? I wouldn’t rely just on the fact that debug bar or whatever is telling you where the view is loading from..
Alfatic
Alfatic6mo ago
@Andrew Wallo Sorry, I had to go away. Now, I am back. This is what I see when I edit the original file in vendor/stechstudio/filament-impersonate/resources/views/components/banner.blade.php
No description
Alfatic
Alfatic6mo ago
It works like that. But obviously this is the wrong thing to do that. It's very puzzling why it's loading the vendor-published file only for the case when not impersonating. What could be the culprit? There is some logic that force-load the original file in impersonation mode no matter what, for some reason. Is it because of the config part? I haven't exported config file
awcodes
awcodes6mo ago
try clearing your view cache
Alfatic
Alfatic6mo ago
@awcodes storage/framework/views and all files there?
awcodes
awcodes6mo ago
php artisan view:clear or if you want a full reset php artisan optimize:clear
Alfatic
Alfatic6mo ago
ok @awcodes I have tried but it's not working.
awcodes
awcodes6mo ago
I personally think you are going about this the wrong way though. it would be better to fork the plugin and use your own copy of it instead of trying to override views.
Alfatic
Alfatic6mo ago
If I change the composer vendor file it reloads immediately with the change
awcodes
awcodes6mo ago
well, changing the vendor file is something you should never do. that's why it would be better to create a fork and use that.
Alfatic
Alfatic6mo ago
yeah, I know. But it drives me crazy
awcodes
awcodes6mo ago
so stop wasting time with the views, fork and move on 🙂
Alfatic
Alfatic6mo ago
what condition makes it load the file only for the one state and not the other like it doesn't make any sense have you seen the last two or three images of mine? once it loads correctly and then back to the original file
awcodes
awcodes6mo ago
honestly, i don't know anything about the plugin, so I can't really tell you anything about it
Alfatic
Alfatic6mo ago
How would you go about debuggin this case. Which file is the one that loads everyting in the plugin? the service provider file?
awcodes
awcodes6mo ago
sorry, i don't know. again, i don't use the plugin so don't know anything about how it was developed
Alfatic
Alfatic6mo ago
No description
Lara Zeus
Lara Zeus6mo ago
I did published the views of the impersonate plugin and overwrite it, and it did worked fine! IDK why it didnt work for you?!
Alfatic
Alfatic6mo ago
What did you change?
Lara Zeus
Lara Zeus6mo ago
whatever it works also did this as you showed
Alfatic
Alfatic6mo ago
@Lara Zeus Can you send me the link to the version you have used? I will try that one Take a look in composer file for the version in composer lock i think I published config and I can change the color and stuff, but the view doesn't work as it should. Is it possible to publish FilamentImpersonateServiceProvider.php ? If so, how?
Lara Zeus
Lara Zeus6mo ago
ok found out that changing the view works fine in filament but not the frontend like the weclome page how you calling the banner in that file? use <x-filament-impersonate::banner /> not <x-impersonate::banner style='light'/>
Alfatic
Alfatic6mo ago
Yeah, in welcome page it's not working In welcome page I have it like this:
<body class="antialiased">
<x-impersonate::banner />
<div
<body class="antialiased">
<x-impersonate::banner />
<div
Solution
Lara Zeus
Lara Zeus6mo ago
change it to <x-filament-impersonate::banner />
Alfatic
Alfatic6mo ago
Yes Finally! THANKS A LOT MAN!
Lara Zeus
Lara Zeus6mo ago
it clould be a typo in the readme of the plugin not sure didn't debug farther you're welcome 🙂
Alfatic
Alfatic6mo ago
Man, it was insane. But finally it works. Again, thanks.