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

Rebuild template layer #8117

Open
wbloszyk opened this issue Oct 8, 2023 · 6 comments
Open

Rebuild template layer #8117

wbloszyk opened this issue Oct 8, 2023 · 6 comments
Labels

Comments

@wbloszyk
Copy link
Member

wbloszyk commented Oct 8, 2023

Feature Request

Current system have one template (AdminLTE2) and it is depends of some bundle config. This solution is hard to keep BC becouse depends of so many third part packages.

Now all templates are taken from sonata.admin.global_template_registry. Some sonata_admin.options should be move there. Also templateRegistry should be moved to pool. This solution will make templates replaceable without BC break.

From this:

sonata_admin:
    options:
        skin: 'skin-black'
        use_select2: true
        use_icheck: true
        use_bootlint: false
        use_stickyforms: true

    templates:
        user_block: '@SonataAdmin/Core/user_block.html.twig'
        ....
        knp_menu_template: '@SonataAdmin/Menu/sonata_menu.html.twig'
        form_theme: []
        filter_theme: []

To this:

sonata_admin:
    default_template: adminlte2
    templates:
        adminlte2:
            user_block: '@SonataAdmin/Core/user_block.html.twig'
            ....
            knp_menu_template: '@SonataAdmin/Menu/sonata_menu.html.twig'
            form_theme: []
            filter_theme: []
            options:
                skin: 'skin-black'
                use_select2: true
                use_icheck: true
                use_bootlint: false
                use_stickyforms: true
        bootstrap5: # adminLTE3, tabler, or any otherr
            user_block: '@JonDoeAdmin/Core/user_block.html.twig'
            ....
            knp_menu_template: '@JonDoeAdmin/Menu/sonata_menu.html.twig'
            form_theme: []
            filter_theme: []
            options:
                skin: 'black'
        another_custom_template:
            ....
@wbloszyk wbloszyk mentioned this issue Oct 8, 2023
5 tasks
@core23
Copy link
Member

core23 commented Oct 8, 2023

Not sure if I understand your idea correctly, but what about making the admin bundle extendable?

For example the SonataAdminBundle only provides a basic theme (e.g. latest bootstrap version). And if you want to use some other theme like AdminLTE2 you could use something like SonataAdminLTE2Theme. The basic theme should also not contain any options.

I know this would mean an other more library to maintain but that might solve some issues and reduces the overall project artifact size.

I'm also not sure how to provide features that require code on the template side, like options you pass from the PHP component to the template to change some theme specific code like this:

'box_class' => 'box box-primary',
'empty_message' => 'message_form_group_empty',
'empty_message_translation_domain' => 'SonataAdminBundle',

@core23 core23 mentioned this issue Oct 8, 2023
21 tasks
@wbloszyk
Copy link
Member Author

wbloszyk commented Oct 8, 2023

Think about sonata.admin.global_template_registry as a sonata.admin.adminlte2_template_registry. From tamplate pool you can take any added template (adminLte2, adminLte3, bootstrap4, bootstrap5 ...) as sonata.admin.global_template_registry alias. It means you can deprecate adminLTE2 in favor of other template in next major release.

Now template options (or templates config). We can check them by validating when adding template registry to pool. In this case we can force templates creator to add options like box_class to them templates. Also they will be able to add extra config depends of them template.

@matik955
Copy link

matik955 commented Nov 8, 2023

Hi, any news on this?

@wbloszyk
Copy link
Member Author

wbloszyk commented Nov 8, 2023

Hi, any news on this?

Hi @matik955. For do it in the best way for all sonata bundles (and my own projects) i had to check all of them. SonataAdminBundle have own template_registry system, SonataPageBundle haven't. Also using SonataAdminBundle to generate template system for own project is bad idea. So the best option will be move it to twig-components or create new bundle.

SonataAdminBundle have also some bad solutions for that. like copy template_registry which should be extended istead:

https://github.com/sonata-project/SonataAdminBundle/blob/5.x/src/DependencyInjection/Compiler/AddDependencyCallsCompilerPass.php#L505-L517

To sum up, I am starting work on a new, independent template system that will enable defining a list of templates, their options and allowing them to be extended. After that we can add it to SonatAdminBundle 4.x as secondary template system. I should finish it this month, but I'm working after hours, so it's better to assume by the end of the year.

@toooni
Copy link
Contributor

toooni commented Apr 30, 2024

HI @wbloszyk
Any news here? I am at a point where I'd like to write our own templates (if possible by using tailwind). Since these changes would affect these plans, I wanted to know if a financial incentive would help. We would be interested in paying you for your time on this feature. If you are interested, what is the ETA and the cost for this implementation?

@wbloszyk
Copy link
Member Author

wbloszyk commented May 6, 2024

Hi @toooni
I suspended contributing some time ago, becouse I open my own company and now I focus on two big project. Back to this issue, I should have some PR and notes. I can check it. Of course a financial incentive will be greate reason to finnaly done this but mybe even better will be help with new frontend. Please send me email with contact (whatsapp will be greate). IMO better will be talk about it.

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

No branches or pull requests

4 participants