maZahaca / sonata-admin-tree-bundle

This bundle integrates jsTree and Gedmo Nested Set directly to Sonata Admin
MIT License
30 stars 19 forks source link

Sonata navbar with filters and view modes missing #11

Open phso opened 4 years ago

phso commented 4 years ago

we work on a projekt with symfony 4 and sonata. we are using the SonataAdminTreeBundle to manage our Categories.

symfony packages:

sonata packages:

basically everything works fine - but the menu from sonata were the datagrid filters are located (aka navbar) is not showing up. in that menu you can usually switch the view modes (grid, list, tree) and set up some filters. it worked at the start but once i tried the tree view for the first time, everything was gone and did not show up again.

so what we basically do is: src/Admin/CategoryAdmin:

namespace App\Admin;

use RedCode\TreeBundle\Admin\AbstractTreeAdmin;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Form\FormMapper;
use Symfony\Component\Form\Extension\Core\Type\TextType;

final class CategoryAdmin extends AbstractTreeAdmin
{

    protected function configureFormFields(FormMapper $formMapper)
    {
        $formMapper->add('name', TextType::class);
    }

    protected function configureDatagridFilters(DatagridMapper $datagridMapper)
    {
        $datagridMapper->add('name');
        $datagridMapper->add('product_id');
    }

    protected function configureListFields(ListMapper $listMapper)
    {
        $listMapper->addIdentifier('name');
    }
}
krixer commented 4 years ago

Same here, I solved extending tree.html.twig template from this bundle and adding these blocks from base_list.html.twig layout from sonata admin:

{%- block tab_menu -%}
    {{ knp_menu_render(admin.sidemenu(action), {
        'currentClass': 'active',
        'template': get_global_template('tab_menu_template')
    }, 'twig') }}
{%- endblock -%}

{% block title %}
    {{ admin.isChild and admin.parent.subject ? 'title_edit'|trans({'%name%': admin.parent.toString(admin.parent.subject)|truncate(15) }, 'SonataAdminBundle') : '' }}
{% endblock %}

{% block navbar_title %}
    {{ admin.isChild and admin.parent.subject ? 'title_edit'|trans({'%name%': admin.parent.toString(admin.parent.subject)|truncate(100) }, 'SonataAdminBundle') : '' }}
{% endblock %}