sonata-project / SonataAdminBundle

The missing Symfony Admin Generator
https://docs.sonata-project.org/projects/SonataAdminBundle
MIT License
2.11k stars 1.26k forks source link

Allow use other layout like AdminLTE 3 #6388

Closed wbloszyk closed 3 years ago

wbloszyk commented 4 years ago

For now we use AdminLTE2 based on bootstrap 3. After add webpack tools to create new custom layout we should add new options for AdminBundle too. My idea is add options:

sonata_admin:
    layout: admin_lte2 # admin_lte2 or admin_lte3
    custom_layouts:
        my_custom_layout: dir_to_files

Information about layout will be add to TemplateRegistry. New files for supported layouts will be add in Resources/views/layouts.

TODO

wbloszyk commented 3 years ago

We start working on improve assets system in SonataAdminBundle - https://github.com/sonata-project/SonataAdminBundle/pull/7034#issue-613028287. Add support for AdminLTE 3 is one of the steps.

I made some review and found:

IMO we should consider to move this feature to the 4.0 milestone. It will allow use AdminLTE 2 for legacy projects which want upgrade AdminBundle without upgrade bootstrap and allow us to add AdminLTE v4 without BC-break.

WDYT? @sonata-project/contributors

VincentLanglet commented 3 years ago

See https://github.com/sonata-project/SonataAdminBundle/issues/7049#issuecomment-818612346

IMHO the stable 4.0 should be release soon. Starting a new big work is not a good idea IMHO. Plus, using AdminLTE 3 instead of 2 will lead to a lot of BC-break, I think we have enough BC-break for 4.0.

The next major release will be made more often, so we don't have to hurry now to take as much feature as possible for the 4.0.

core23 commented 3 years ago

IMHO the stable 4.0 should be release soon. Starting a new big work is not a good idea IMHO. Plus, using AdminLTE 3 instead of 2 will lead to a lot of BC-break, I think we have enough BC-break for 4.0.

👍

I'm not sure if we can find a way to provide support for two different themes, because we use a lot of template overrides and twig blocks. Supporting two major html frameworks requires a lot of work and maintenance.

wbloszyk commented 3 years ago

IMHO the stable 4.0 should be release soon. Starting a new big work is not a good idea IMHO. Plus, using AdminLTE 3 instead of 2 will lead to a lot of BC-break, I think we have enough BC-break for 4.0.

👍

I'm not sure if we can find a way to provide support for two different themes, because we use a lot of template overrides and twig blocks. Supporting two major html frameworks requires a lot of work and maintenance.

It is simple to do. We should copy all current templates to the views/adminLTE2. In @SonataAdmin/layout.html.twig we should keep:

{% include '@SotataAdmin/'~global_admin_layout_parameter~'/layout.html.twig' %}

It can be also easy extends by users.

core23 commented 3 years ago

The copy & paste stuff from the main template should be easy, but we must provide for all child template (e.g. blocks). They must work with admin lte 2 (bootstrap 3) and admin lte 3 (bootstrap 4). It looks very difficult to me, but feel free to provide a PR.

Keep in mind that the template rendering time might explode with too many if/else statements on the child templates.

jordisala1991 commented 3 years ago

IMHO having to maintain this double template files is a huge maintenance source of problems. And opens a world of having more different layouts requested.

If @sonata-project/contributors feel like this is the way to go, please open, I will close it for now, since the original pr is also closed.

VincentLanglet commented 3 years ago

IMHO having to maintain this double template files is a huge maintenance source of problems. And opens a world of having more different layouts requested.

If @sonata-project/contributors feel like this is the way to go, please open, I will close it for now, since the original pr is also closed.

I agree

djpretzel commented 3 years ago

The best way of supporting this type of feature request would be to convert Sonata to essentially provide its own REST API and to use that API across the board with the frontend template, which would be a pretty big change that would (more or less) deprecate Twig templating in favor of Vue, Angular, React, etc.

The default template could favor a specific JS framework and provide a reference implementation, and additional frontends could be developed, plus the REST API could be usable in other contexts, potentially. But at that point it's a pretty major rewrite.... maybe for Sonata 6? :)