drago-ex / project-backend-ui
Integration of a basic template for administration.
Package info
github.com/drago-ex/project-backend-ui
Language:Latte
Type:project
pkg:composer/drago-ex/project-backend-ui
Requires
- php: >=8.3 <9
- drago-ex/project-auth: ^1.0
- drago-ex/project-backend: ^1.0
- drago-ex/project-user: ^1.0
Requires (Dev)
- drago-ex/project-installer: @dev
- phpstan/phpstan-nette: ^1.2.9
This package is auto-updated.
Last update: 2026-05-19 16:07:26 UTC
README
Integration of a basic template for administration.
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.