AdminLTE theme for CakePHP 3
![Build status][build svg]
![License][license svg]
![Total downloads][downloads svg]
, (*1)
Installation
You can install this plugin into your CakePHP application using composer., (*2)
The recommended way to install composer packages is:, (*3)
composer require ciricihq/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 can easily use the AdminLTE template making your controllers
extend the AdminLTE AppController
:, (*7)
use Cirici\AdminLTE\Controller\AppController as BaseController;
class MyController extends BaseController
{
}
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'
]
]
];
Login template
A login template and layout are included too. To use them, simply render the
login Template from you login
method:, (*10)
// some kind of users Controller
public function logic()
{
// [...]
// Your login logic
$this->render('Cirici/AdminLTE./Admin/Users/login');
}
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:, (*11)
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:, (*12)
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., (*13)
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., (*14)
If you're setting menu items using php you would do something like this:, (*15)
$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:, (*16)
<?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., (*17)
For this reason, we recommend creating a custom layout which your views will extend., (*18)
Create an admin.ctp
file wherever you want, add there your custom AdminLTE
view blocks, and then make your views extend that layout:, (*19)
<?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:, (*20)
<?php
$this->extend('/admin');
Here are all the currently defined view blocks:, (*21)
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., (*22)
License
Created by Òscar Casajuana for Cirici New Media, (*23)
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/>.