Easyadminbundle: use custom "route" like a EasyAdmin route

Created on 23 Jan 2017  路  4Comments  路  Source: EasyCorp/EasyAdminBundle

Hi, I have "Abuse" entity and I want to use one of Abuse's functions/routes for the "list" action. And, obviously, I want an entry in the left side menu and the output inside right side.

I have read "https://github.com/javiereguiluz/EasyAdminBundle/blob/master/Resources/doc/book/6-menu-configuration.md#symfony-routes" but this is not my case because the output is open in a new page outside easyadmin template.

How ? Thanks.

M.

Waiting feedback

Most helpful comment

@Uplink03 thanks or your comment. I think I understand the original question now. You are right in your last comment.

When using a Symfony route, your backend "leaves" EasyAdmin ... but in the return $this->render(...) of your controller you can render a template in your application that extends any of the default templates of the bundle. If you want to make minor changes, just override some of the blocks defined in those templates. If you just want to maintain the main layout and the menu navigation, use the template shown by @Uplink03:

{% extends "@EasyAdmin/default/layout.html.twig" %}

{% block main %}
Your custom content that you want to see in EasyAdminBundle context.
{% endblock %}

Closing it as "fixed" then. Thanks!

All 4 comments

I'm not sure I understand the problem ... but if you just need to open the custom route in a new browser window, you can do that with the target config option, as explained in https://github.com/javiereguiluz/EasyAdminBundle/blob/master/Resources/doc/book/6-menu-configuration.md#targets

I'm thinking @ziobudda wants the following, which I also want: an ability to have non-entity Admins.

This could work if one could define an "entity" without the class parameter. To not confuse matters too much, maybe such an entity shouldn't have the usual actions (list, edit, delete, ...), but instead have a block action and its sole purpose would be to embed a twig template or a controller in the admin layout.

How such a configuration might look like:

  • config.yml
easy_admin:
    entities:
        BlockEntity1:
            block:
                controller: 'AppBundle:Block:index'
                params: { param_name: 'param_value' }
        BlockEntity2:
            block:
                template: '@AppBundle/Block/index.html.twig'
                params: { param_name: 'param_value' }

Alternatively, you could have a new blocks key to keep this feature apart from entities.

  • EasyAdmin Twig template would contain this sort of code:
    {{ render(controller(block_controller, block_parameters)) }}
    {{ include block_template with block_parameters }}

A solution that doesn't require any changes to EasyAdminBundle:

Make your Twig template like this:

{% extends "@EasyAdmin/default/layout.html.twig" %}

{% block main %}
Your custom content that you want to see in EasyAdminBundle context.
{% endblock %}

@Uplink03 thanks or your comment. I think I understand the original question now. You are right in your last comment.

When using a Symfony route, your backend "leaves" EasyAdmin ... but in the return $this->render(...) of your controller you can render a template in your application that extends any of the default templates of the bundle. If you want to make minor changes, just override some of the blocks defined in those templates. If you just want to maintain the main layout and the menu navigation, use the template shown by @Uplink03:

{% extends "@EasyAdmin/default/layout.html.twig" %}

{% block main %}
Your custom content that you want to see in EasyAdminBundle context.
{% endblock %}

Closing it as "fixed" then. Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Wait4Code picture Wait4Code  路  3Comments

seb-jean picture seb-jean  路  3Comments

Farshadi73 picture Farshadi73  路  4Comments

BigMichi1 picture BigMichi1  路  3Comments

cve picture cve  路  4Comments