drago-ex/project-backend-ui

There is no license information available for the latest version (dev-main) of this package.

Integration of a basic template for administration.

Maintainers

Package info

github.com/drago-ex/project-backend-ui

Language:Latte

Type:project

pkg:composer/drago-ex/project-backend-ui

Statistics

Installs: 8

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

dev-main 2026-05-19 16:07 UTC

This package is auto-updated.

Last update: 2026-05-19 16:07:26 UTC


README

Integration of a basic template for administration.

License: MIT PHP version Coding Style

Requirements

  • PHP >= 8.3
  • Nette Framework
  • Composer
  • Bootstrap
  • Naja
  • Node.js
  • Drago Project core packages

Installation

composer require drago-ex/project-backend-ui

Install npm

npm install sidebar-skeleton-compostrap sidebar-menu-compostrap dashboard-skeleton-compostrap perfect-scrollbar

This package is based on Dashboard Skeleton.

Use admin-theme.js

import { initAdminTheme } from "admin-theme.js";
document.addEventListener("DOMContentLoaded", () => {
	initAdminTheme();
});

Creating a Menu

The menu is typically created in a base presenter for the administration (e.g., BackendPresenter).

private function getSidebarMenuStructure(): array
{
	$builder = new SidebarBuilder;
	
	// Sections are optional and serve as titles/separators
	$builder->addSection('System')
		// Simple link with icon
		->addItem('Dashboard', 'Admin:')
		->setIcon('fa-solid fa-mug-hot bell')

		// Complex item with permissions and submenu
		->addItem('Permissions', 'AccessControl:*')
		->setIcon('fa-solid fa-gear bell')
		->setAllowAny('Backend:AccessControl', 'roles-read', 'users-read')
		->addSubItem('Roles', 'AccessControl:roles', ['Backend:AccessControl', 'roles-read'])
		->addSubItem('Users', 'AccessControl:users', ['Backend:AccessControl', 'users-read']);

	return $builder->build();
}

Then pass it to the template in beforeRender:

protected function beforeRender(): void
{
	parent::beforeRender();
	$this->template->sidebarMenu = $this->getSidebarMenuStructure();
}

Menu Composition Guide

  • addSection(string $title) - (Optional) Creates a new group of items with a visible header (title). Use this when you want to visually separate different parts of the menu. If skipped, items will be grouped together without a title.

  • addItem(string $title, string $link) - Adds a primary link to the sidebar. If you only use this method, it renders as a direct link. If followed by addSubItem, it automatically becomes a dropdown toggle for the submenu.

  • setIcon(string $icon) - Attaches a FontAwesome icon (e.g., fa-solid fa-user) to the last added primary item.

  • addSubItem(string $title, string $link, ?array $allow = null) - Adds a child link to the last added primary item, automatically turning it into a submenu.

Integration with project-permission

If you are using the project-permission package, the menu automatically handles visibility based on user privileges.

  • setAllowAny(resource, ...privileges) - The main item is displayed if the user has at least one of the specified privileges for the given resource.

  • addSubItem(..., [resource, privilege]) - The sub-item is displayed only if the user has the exact privilege for the given resource.