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?
59 Replies
what plugin?
@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.
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
you should publish views by plugin I think@Leandro Ferreira How to do that?
check the plugin page if it is available
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
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"
Thanks, is this universal or the plugin creator have to support this somehow?
plugin creator
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?
should work in the resources/views/vendor I think
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
@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:
GitHub
filament-impersonate/resources at master · stechstudio/filament-imp...
Filament plugin that makes it easy to impersonate your users - stechstudio/filament-impersonate
I will appreciate any help Leonardo.
create this file
resources/views/vendor/filament-impersonate/components/banner.blade.php
Copy/paste the original content and edit what you wantThanks, it's insane.
I can add stuff to above but this part here:
if I try:
it's not showing.
But this:
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:
I think you have a way to do it now
Maybe you can check this on the plugin channel
#impersonate
I have asked there but it's empty there.
It's weird because I see this in debugbar
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
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:But when impersonating it take the incorrect one:
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?Just type in the console “php artisan vendor:publish” and you will see a list of all package views you can publish
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:But if I directly change it in the composer vendor folder like this:
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..
@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
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 filetry clearing your view cache
@awcodes storage/framework/views and all files there?
php artisan view:clear
or if you want a full reset php artisan optimize:clear
ok
@awcodes I have tried but it's not working.
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.
If I change the composer vendor file it reloads immediately
with the change
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.
yeah, I know.
But it drives me crazy
so stop wasting time with the views, fork and move on 🙂
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
honestly, i don't know anything about the plugin, so I can't really tell you anything about it
How would you go about debuggin this case.
Which file is
the one that loads everyting in the plugin?
the service provider file?
sorry, i don't know. again, i don't use the plugin so don't know anything about how it was developed
I did published the views of the impersonate plugin and overwrite it, and it did worked fine!
IDK why it didnt work for you?!
What did you change?
whatever it works
also did this as you showed
@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?
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'/>
Yeah, in welcome page it's not working
In welcome page I have it like this:
Solution
change it to
<x-filament-impersonate::banner />
Yes
Finally!
THANKS A LOT MAN!
it clould be a typo in the readme of the plugin not sure didn't debug farther
you're welcome 🙂
Man, it was insane. But finally it works. Again, thanks.