2017 © Pedro Peláez
 

cakephp-plugin adminlte

AdminLTE theme for CakePHP

image

funayaki/adminlte

AdminLTE theme for CakePHP

  • Thursday, June 14, 2018
  • by tsmsogn
  • Repository
  • 1 Watchers
  • 0 Stars
  • 76 Installations
  • JavaScript
  • 1 Dependents
  • 0 Suggesters
  • 4 Forks
  • 2 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

AdminLTE theme for CakePHP 3

![Build status][build svg] Code coverage ![License][license svg] Latest stable version ![Total downloads][downloads svg] Code climate, (*1)

Requirements

  • cakephp-adminlte-theme(https://github.com/funayaki/cakephp-adminlte-theme)

Installation

You can install this plugin into your CakePHP application using composer., (*2)

The recommended way to install composer packages is:, (*3)

composer require funayaki/adminlte

Installing dependencies

Currently this theme uses NPM to install external dependencies such as bootstrap, fontawesome or the AdminLTE itself., (*4)

To install all the dependencies, just run (within the plugin folder):, (*5)

npm install && ./node_modules/gulp/bin/gulp.js

Configuration

First you need to load the plugin. To do so, edit your bootstrap.php file and add line below:, (*6)

Plugin::load('Cirici/AdminLTE', ['bootstrap' => true]);

After that, you need to update the app AppController:, (*7)

class AppController extends Controller
{

    public $helpers = [
        'Gourmet/KnpMenu.Menu',
        'Breadcrumbs'
    ];

    public function initialize() {
        parent::initialize();

        $this->loadComponent('Gourmet/KnpMenu.Menu');
    }

    /**
     * @param Event $event
     * @return void
     */
    public function beforeRender(Event $event)
    {
        $this->viewBuilder()->setTheme('Cirici/AdminLTE');
    }
}

Usage

First of, take a look to the bootstrap.php file to see what can you configure with Configure., (*8)

To load your custom configurations you can obviously use Configure::write where you need, but the recommended way is creating a adminlte.php file under your CONFIG folder (usually /config):, (*9)

<?php
// /config/adminlte.php
return [
    'AdminLTE' => [
        'texts' => [
            'logo' => '<b>Awesome</b>Admin'
        ]
    ]
];

This plugin uses KnpMenu for managing its menus and also includes a Yaml parser so you can easily create your menus with just three lines of code and a yaml file:, (*10)

use Cake\Event\EventManager;
use Cirici\AdminLTE\Renderer\YamlMenuParser;

EventManager::instance()->on('AdminLTE.menu.sidebar', function ($event, $menu) {
    $yaml = new YamlMenuParser($menu, 'admin_menu_sidebar.yaml');
});

With a yaml file like this one:, (*11)

Settings:
  uri: '#'
  attributes:
    icon: gears
  children:
    Users:
      uri: /admin/users
      attributes:
        icon: users
      children:
        Add user:
          uri: /admin/users/add
          attributes:
            icon: user-plus
    Roles:
      uri: /admin/roles
      attributes:
        icon: suitcase

Currently there's only the sidebar menu bar defined in the template., (*12)

Note that there's a special attribute icon so you can easily display FontAwesome icons on your menu. Just use the icon name and the AdminLTERenderer will do the rest., (*13)

If you're setting menu items using php you would do something like this:, (*14)

$posts = $menu->addChild('Posts', [
    'uri' => ['_name' => 'posts.admin.index'],
    'icon' => 'newspaper-o'
]);
$posts->addChild('Add posts', [
    'uri' => ['_name' => 'posts.admin.add'],
    'icon' => 'plus'
]);

Crumbs

Add crumbs using the BreadcrumbsHelper::add method:, (*15)

<?php
$this->Breadcrumbs->add('Posts', '/posts');
$this->Breadcrumbs->add($yourCurrentPost->title);

View blocks

Many sections of the layout can be managed just defining some view blocks., (*16)

For this reason, we recommend creating a custom layout which your views will extend., (*17)

Create an admin.ctp file wherever you want, add there your custom AdminLTE view blocks, and then make your views extend that layout:, (*18)

<?php
// src/Templates/admin.ctp
$this->start('AdminLTE.user.sidebar');
echo 'Hello ' . $this->Session->read('Auth.User.username') . '!';
$this->end('AdminLTE.user.small');

And then, in your views:, (*19)

<?php
$this->extend('/admin');

Here are all the currently defined view blocks:, (*20)

  • subtitle
  • AdminLTE.user.small
  • AdminLTE.user.detail
  • AdminLTE.user.sidebar
  • AdminLTE.sidebar.right

Don't forget to check out the official AdminLTE repository to know how to properly define each section., (*21)

License

Created by Òscar Casajuana for Cirici New Media, (*22)

AdminLTE theme for CakePHP 3
Copyright (C) 2016 Òscar Casajuana

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

The Versions

14/06 2018
27/04 2018

dev-master

9999999-dev

AdminLTE theme for CakePHP

  Sources   Download

GPL-3.0

The Requires

 

The Development Requires

27/04 2018

dev-flash

dev-flash

AdminLTE theme for CakePHP

  Sources   Download

GPL-3.0

The Requires

 

The Development Requires

02/06 2016
09/05 2016