edezacas/base-admin

Symfony 5 Base Admin Bundle with a suite of templates.

Installs: 9

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 0

Language:CSS

Type:symfony-bundle

2.0.0 2023-11-29 10:15 UTC

This package is auto-updated.

Last update: 2024-04-29 11:16:56 UTC


README

Getting Started

This bundle use Bootstrap 5.1.3 and jQuery 3.6.

This bundle includes 2 views with a set of css and js assets:

  • login.html.twig: Simple page layout with a great style.
  • base.html.twig: Minimal Admin layout.

How to use

  1. Enable this bundle at AppKernel o bundles.php:
return [
    Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
    ...
    EDC\BaseAdminBundle\EDCBaseAdminBundle::class => ['all' => true],
];
  1. Add configuration file:
edc_base_admin:
    site_name: 'Site Title'
    login_check: _route_name_or_url_to_login_check
    logout: _route_name_or_url_to_logout
    admin_home: _route_name_or_url_to_admin_homepage

  1. To show login page simply create your own login.html.twig and add:
{% include ('@EDCBaseAdmin/login.html.twig') %}
  1. For admin layout, create a template called for example layout.html.twig and add:
{% extends '@EDCBaseAdmin/base.html.twig' %}

{% block title %} _YOUR_CUSTOM_HTML_TITLE_ {% endblock %}

{% block sidebar %}
    _YOUR_CUSTOM_SIDEBAR_MENU_
{% endblock %}

{% block dropdown %}
    _YOUR_CUSTOM_DROPDOWN_MENU_BELOW_USERNAME_
{% endblock %}

{% block footer %}
   _YOUR_CUSTOM_FOOTER_BELOW_USERNAME_
{% endblock %}

  1. And at last, for each page inside admin control panel, you only need to extends from your layout.html.twig. For example, for dashboard.html.twig:
{% extends 'admin/layout.html.twig' %}

{% block content %}
    _YOUR_DASHBOARD_CONTENT_PAGE_
{% endblock %}

Bonus

Form Themes

By default we add the Bootstrap 5 Form Themes, also we have improved:

  • VichImageWidget: Added class "img-thumbnail" from Bootstrap 5 to image preview.

  • FilepondType: An usefull Form AbstractType that help us to upload multiple (or single) files/images. A compounded type with 2 childs:

    • Childs:
      • uploader: FileType field to handle file uploads.
      • files: HiddenType field to handle list of files uploaded.
    • Options:
      • 'multiple' => Allow upload multiple files (Bool)
      • 'uploadUri' => Path to request for upload files (String)
      • 'removeUri' => Path to request for remove files (String)
      • 'files' => A simple array containing paths to show images,
      • 'acceptedFileTypes' => List (coma separated) of allowed Mime Types (String)