Custom Back End Sidebar for Listview Page (override backend/layouts/default.php)

Using builder/builder backend menu:

I have been trying to figure out a better way to work with categories/subcategories because I need them to be relational, but I really don’t want to have to put them in a menu drop down because that is going to get very big very fast.

Assuming my main menu item is called Strata and I have the sub-items Transactions, Fees, Invoices.

When clicking Transactions, how would I go about overriding the backend list view so that the sidebar on the left doesn’t show all of the sibling menu items but instead would show Transaction Categories and Transaction Subcategories (just links to their respective list views really).

When I click on Fees in the menu, it would give me the fees list view, but on the left sidebar would show Fee Categories and Fee Subcategories the same way Transactions would work.

The “problem” is in the modules/backend/layouts/default.php file. Removing the Side Navigation code solves the problem, but I just need it gone for my transactions/fees/invoices list views. Can backend/layout/*.php files not be overridden?

Thanks!

Hi @theshado40

The documentation has an example of adding a sidebar to a list. It is commonly used to have a more prominent list filtering area, for the same list.

If using multiple lists, you could just include the sidebar in the view file (index.php) using a column layout. You can find an example of rendering multiple lists in the test plugin, in the Posts menu item, it uses horizontal tabs.

Finally, you should be able to manipulate the Backend\Classes\NavigationManager to remove the sidebar items and replace them with new ones based on the URI parameters. This would make the sidebar essentially dynamic. The best place to put this event is inside the beforeDisplay controller method override.

public function beforeDisplay()
{
    Event::listen('backend.menu.extendItems', function($manager) {
        $manager->removeSideMenuItems('Acme.Blog', 'blog', [
            'posts',
            'categories'
        ]);
    });
}

See the navigation documentation for more on this:

1 Like

Thanks for the quick reply daftspunky!

I actually familiarized myself with both the navigation and list controller links before asking (been at this all day=) )… The list controller would be great because I can just cut/paste the default.php code and simply get rid of the sidebar in the _list_container.php file, but unfortunately the ‘left navigation’ remains.

Manipulating the navigation manager would be the most ideal, but removeSideMenuItems also removes them from the main menu dropdown or it would be perfect.

I’m sure I can work around all of this in the meantime. Thanks again!