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

Add render block controller #42

Closed
bitbager opened this issue Oct 18, 2017 · 2 comments
Closed

Add render block controller #42

bitbager opened this issue Oct 18, 2017 · 2 comments

Comments

@bitbager
Copy link
Member

bitbager commented Oct 18, 2017

For now, we are rendering block through the Twig function. I think that making it with a custom controller would be more flexible as it can have an optional template parameter. Sometimes the default CMS Block templates are not enough. What I would like to achieve is I want it to be rendered like this: {{ render(path('bitbag_cms_render_block', {'code' : 'homepage_slide_1', 'template' : '@App/Cms/homepageSlide.html.twig'})) }} instead of {{ bitbag_render_block('homepage_slide_1') }}. Maybe it would be also a nice idea to allow an optional parameter to the bitbag_render_block function for a template.

bitbager pushed a commit to bitbager/SyliusCmsPlugin that referenced this issue Nov 5, 2017
@kochen
Copy link
Contributor

kochen commented Nov 7, 2017

@bitbager thanks to the ResourceController this is already possible by simple adding to routing.yml:

bitbag_shop_partial_block_index_by_code:
    path: /by-code/{code}
    methods: [GET]
    defaults:
        _controller: bitbag.controller.block:indexAction
        _sylius:
            template: $template
            repository:
                method: findOneByCode
                arguments:
                    - $code

and then in your template you could render a block with:

{{ render(url('bitbag_shop_partial_block_index_by_code', {'code': 'my_image_block', 'template': '@BitBagCmsPlugin/Shop/Block/imageBlock.html.twig'})) }}

@bitbager
Copy link
Member Author

Implemented ✅

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

2 participants