1. Go to this page and download the library: Download zanysoft/laravel-theme 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/ */
// Select a name for your theme
'themes' => [
'theme-name' => [
/*
|--------------------------------------------------------------------------
| Theme to extend. Defaults to null (=none)
|--------------------------------------------------------------------------
*/
'extends' => 'theme-to-extend',
/*
|--------------------------------------------------------------------------
| The path where the view are stored. Defaults to 'theme-name'
| It is relative to 'themes_path' ('/resources/views' by default)
|--------------------------------------------------------------------------
*/
'views-path' => 'path-to-views',
/*
|--------------------------------------------------------------------------
| The path where the assets are stored. Defaults to 'theme-name'
| It is relative to laravels public folder (/public)
|--------------------------------------------------------------------------
*/
'asset-path' => 'path-to-assets',
/*
|--------------------------------------------------------------------------
| Custom configuration. You can add your own custom keys.
| Use Theme::getSetting('key') & Theme::setSetting('key', 'value') to access them
|--------------------------------------------------------------------------
*/
'key' => 'value',
],
],
Theme::getSetting('key','default'); // read current theme's configuration value for 'key'
Theme::setSetting('key','value'); // assign a key-value pair to current theme's configuration
Theme::Set('ThemeA'); // ThemeA is Active
theme_url('image1.jpg'); // = /image1.jpg
theme_url('image2.jpg'); // = /ThemeA/image2.jpg
theme_url('image3.jpg'); // = /ThemeA/image3.jpg
Theme::Set('ThemeB'); // ThemeB is Active, it extends ThemeA
theme_url('image1.jpg'); // = /image1.jpg
theme_url('image2.jpg'); // = /ThemeA/image2.jpg
theme_url('image3.jpg'); // = /ThemeB/image3.jpg
Theme::set('theme-name'); // switch to 'theme-name'
Theme::get(); // retrieve current theme's name
Theme::current(); // retrieve current theme (insance of ZanySoft\LaravelTheme\Theme)
Theme::exists('theme-name'); // Check if 'theme-name' is a registered theme
Route::group(['prefix' => 'admin', 'middleware'=>'setTheme:ADMIN_THEME'], function() {
// ... Add your routes here
// The ADMIN_THEME will be applied.
});