Milk Admin

Introduction

The graphic theme of this administrative system is based on bootstrap.

The base system is very simple - the Route registers a function for each page and inside the function you can print a page within the theme by writing:

Response::themePage('default', __DIR__ . '/assets/my.page.php', ['title' => 'My Page' ...]);

This function loads the theme and prints the page indicated as the second parameter as content.

The third parameter is an array of variables that are passed to the page.

Edit other theme elements

To modify other theme elements you can use the Theme::set() function.

For example:

Theme::set('header.title', 'My Page');

This function allows you to modify the header title.

Adding a custom header link

For example:

Theme::set('header.links', [ 'title' => 'My custom link', 'url' => Route::url('?page=my-custom-page&action=my-custom-action'), 'icon' => 'bi bi-cup-hot-fill', 'order' => 30]);

This function allows you to add a custom link to the header.

Header link
Adding a sidebar menu link
Header link
Hooks::set('init', function($page) {
    if (Permissions::check('_user.is_admin')) {
        Theme::set('sidebar.links', [
            'url' => Route::url('?page=a-cup-of-milk'), 
            'title' => 'A cup of milk?', 
            'icon' => 'bi bi-cup-hot-fill', 
            'order' => 1
        ]);
    }
});
breadcrumb

The space at the top left is called breadcrumb and is an html space that you can modify like this:

Theme::set('header.top-left', 'my cup of milk > Sugar');

Plugins

The theme has a plugins folder in which there are some HTML/JavaScript elements that can be used to extend the theme's functionality.

For example the preloader:

<?php echo Get::themePlugin('loading', ['id' => 'loading']); ?>
<script>
document.addEventListener('DOMContentLoaded', function() {
    new Loading('.js-ito-loading').show();
});
</script>
Loading...

Bootstrap components

The use of various bootstrap components has been simplified with JavaScript classes that activate their functionality

Load theme page

Remember that once you've prepared the variables to load on a template to integrate everything into a theme page, you'll just need to write

Response::themePage('default', __DIR__ . '/cup-module/assets/milk.page.php', ['my_var'=>'drink']);

Inside your page you can call the my_var variable and print it simply by writing _p($my_var);. The _p function prints variables while sanitizing them. In general, always try to avoid printing using echo.

Vanilla Javascript

The theme doesn't use JavaScript frameworks, but has a series of utilities to simplify development, but if desired it's possible to extend the system with any JavaScript framework you want

Loading...