PHP code example of atelfoto / template-admin

1. Go to this page and download the library: Download atelfoto/template-admin library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

atelfoto / template-admin example snippets


// src/Application.php

public function bootstrap()
{
    $this->addPlugin('Admin');
}

//config/routes

Router::prefix('admin', function ($routes)
{
    $routes->connect('/', ['controller' => 'Dashboards', 'action' => 'index']);
    $routes->fallbacks(DashedRoute::class);
});

// src/controller/AppController.php

public function beforeFilter(Event $event)
    {
        if (!is_null($this->request->getParam('prefix'))) {
            $prefix = explode('/', $this->request->getParam('prefix'))[0];

            switch ($prefix) {
                case 'admin':
                    $this->viewBuilder()->setLayout('admin');
                    $this->viewBuilder()->setTheme('Admin');
                    break;
            }
        }
    }

// src/View/AppView.php

public function initialize()
    {
        $this->loadHelper('Form', [
            'templates' => 'Admin.form-template',
        ]);
    }

$parentMenus = $this->Examples->ParentMenus->find('list', ['limit' => 200]);

$parentMenus = $this->Menus->ParentMenus->find(
            'treeList',
            [
                'spacer' => "---- ",
            ]
        );

//template/Admin/Examples/add.ctp
//and
//template/Admin/examples/edit.ctp
echo $this->Form->control('controller');
echo $this->Form->control('online');

//Template/Admin/Menus/index.ctp

<td><?= h($menu->online); 

// config/bootstrap.php

Configure::load('Admin.config-dist', 'default', false);
bash
$this->addBehavior('Admin.Sluggable');