Aggiunga i link alle pagine personalizzate nella barra di navigazione amministrativa di Bootstrap.

Per aggiungere collegamenti a pagine personalizzate nella barra laterale del pannello amministrativo Bootstrap, deve creare la sua pagina, mapparla con il router principale e poi aggiungerla nella barra laterale.


Link a pagine personalizzate nella barra laterale del pannello di amministrazione Bootstrap

  1. Crei il suo file di destinazione in admin/
    cioè: my-custom-page.php
  2. Crei una nuova regola del router in admin/index.php per condurre alla sua nuova pagina.
    Ad esempio: $router->map('GET', '/my-custom-page', 'my-custom-page.php', 'my-custom-page');
  3. Aggiunga la sua pagina alla barra laterale:
    1. apra il file adminincsidebar.php
    2. Aggiunga il seguente codice alla fine del file e lo personalizzi come desidera:
      $active = false;
      
      // test if the page is active using $match from the router.
      // 'my-custom-page' is the name we gave in index.php => $router->map()
      if (isset($match['name']) && $match['name'] == 'my-custom-page') {
      $active = true;
      $is_category_collapsed = false;
      }
      
      // add category
      $sidebar->addCategory('new-category', 'New Category', '', '', true, $is_category_collapsed);
      
      // add nav into category - the 'newCategory' object is the sidebar's newly created category.
      // its name ('newCategory') is the lower-camelcase version of 'new-category'
      $sidebar->newCategory->addNav('my-custom-page', 'nav flex-column');
      
      // add page into nav - the 'myCustomPage' object is the sidebar's category newly created nav.
      // its name ('myCustomPage') is the lower-camelcase version of 'my-custom-page'
      $sidebar->newCategory->myCustomPage->addLink(ADMIN_URL . 'my-custom-page', 'MyCustom Page', 'fas fa-users', $active, 'class=nav-item', 'class=nav-link d-flex align-items-center');
  4. Fatto.

Pagina principale del tutorial PHP CRUD