Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Best way to customize the views? #943

Closed
isometriq opened this issue Jun 30, 2017 · 9 comments
Closed

Best way to customize the views? #943

isometriq opened this issue Jun 30, 2017 · 9 comments

Comments

@isometriq
Copy link

Is there a way I could modify the login form, header or sidebar to apply custom visuals/features ?

I can see that Encore\Admin\Layout\Content renders the view admin::content
Do you know if I can override the view?

Thinking about extending the Content class and override...

@isometriq
Copy link
Author

isometriq commented Jul 1, 2017

Alright! I've found the most clean way I think...
For instance I wanted to override the header.

I've created the folder resources/views/vendor/admin and that's where I will put the same file structure as the package in vendor/encore/laravel-admin/views.

So, for the header, I've copied the file vendor/encore/laravel-admin/views/partials/header.blade.php into vendor/encore/laravel-admin/views/partials/header.blade.php. Then I can modify my copy and it is the file that will be used!

@isometriq
Copy link
Author

Just found the docs about this feature
https://laravel.com/docs/5.4/packages#views

@z-song
Copy link
Owner

z-song commented Jul 3, 2017

Use app('view')->prependNamespace('admin', resource_path('views/admin')); to override the bulitin views.

@z-song z-song closed this as completed Jul 3, 2017
@isometriq
Copy link
Author

Ok, I did not know this method. Seems to allow deciding a specific folder instead of using resource/views/vendor/admin. Good to know.

@oopmvc
Copy link

oopmvc commented Feb 15, 2018

"Use app('view')->prependNamespace('admin', resource_path('views/admin')); to override the bulitin views." - Which file we need to use this?

Also is there any way to add custom JS for each field, like on date change [ date of birth, I will calculate age ], tirgger js code?

@leandroeidi
Copy link

@oopmvc
I don't know why people simply can't give complete answers, instead spilling a single code line like everybody knows how everything in this project connects and expecting us to magically know where to put it.

Anyway, I managed to find this in the chinese docs, and translated it with Google Translate.

Summary of common problems

Override the built-in view

If you need to modify the view yourself, but it is not convenient to directly modify the laravel-admin situation, you can use the following solution
Copy vendor/encore/laravel-admin/views to the project's resources/views/admin and add the code to the app/Admin/bootstrap.php file:

app('view')->prependNamespace('admin', resource_path('views/admin'));

@RNKushwaha
Copy link

How to customize the form view only for some routes like pages/1/edit ?

@lordjack
Copy link

@oopmvc
I don't know why people simply can't give complete answers, instead spilling a single code line like everybody knows how everything in this project connects and expecting us to magically know where to put it.

Anyway, I managed to find this in the chinese docs, and translated it with Google Translate.

Summary of common problems

Override the built-in view

If you need to modify the view yourself, but it is not convenient to directly modify the laravel-admin situation, you can use the following solution
Copy vendor/encore/laravel-admin/views to the project's resources/views/admin and add the code to the app/Admin/bootstrap.php file:

app('view')->prependNamespace('admin', resource_path('views/admin'));

Thanks for your tip @leandroeidi, I tested it and it worked, I was able to customize the Login page and the Dashboard overwriting. In this way I managed to version these source codes

@guardianorion
Copy link

In the new folder version this hierarchy worked for me.
app('view')->prependNamespace('admin', resource_path('views/admin/views'));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants