In this repository, you can find the theme system for the framework PHP, Laravel 7
-
firstly run
composer require isaeken/laravel-theme-system
in your project folder -
migrate new tables to your database using
php artisan migrate
-
create a theme
. ├── assets <- Your asset folder │ ├── css │ │ └── app.css │ └── js │ └── app.js ├── views <- Your view folder │ └── home.blade.php ├── details.json <- Your theme details └── settings.json <- Your theme settings
- in details.json
{ "name": "Your Theme Name", "description": "This is your first!", "version": "1.0", "authors": [ { "name": "İsa Eken", "email": "[email protected]" } ] }
- Note: You can blank to
settings.json
but this file is required. - Convert to
zip
these files.
- in details.json
-
Install your default theme to your project using php
/** * Install a theme file to project * @param string $themeFile * @param bool $setDefault * @return object */ \IsaEken\ThemeSystem\ThemeSystem::install('/your/theme/file.zip', true);
<?php
namespace App\Http\Controllers;
use IsaEken\ThemeSystem\ThemeSystem;
class HomeController extends Controller
{
public function index()
{
$yourData = time();
$yourSecondData = date(time());
return ThemeSystem::view('index', compact('yourData', 'yourSecondData'));
}
}
$theme = \IsaEken\ThemeSystem\Models\Theme::where('name', 'theme_name')->first();
\IsaEken\ThemeSystem\ThemeSystem::change($theme);
if (\IsaEken\ThemeSystem\ThemeSystem::isInstalled('theme_name')) echo 'installed';
else echo 'not installed';
$theme = \IsaEken\ThemeSystem\Models\Theme::where('name', 'theme_name')->first();
\IsaEken\ThemeSystem\ThemeSystem::setDefault($theme);
/**
* @param string $themeName
* @param bool $withFiles = false
* @param bool $forceDelete = false
* @return bool
*/
\IsaEken\ThemeSystem\ThemeSystem::uninstall('theme_name', true, true);
/**
* @return \IsaEken\ThemeSystem\Models\Theme|null
*/
\IsaEken\ThemeSystem\ThemeSystem::theme();
/**
* Get url of client theme asset.
*
* @param string $asset
* @return string
*/
theme_asset('css/app.css');
/**
* Get setting of client theme.
*
* @param string $key
* @return mixed
*/
theme_setting('key.in.settings.json');
/**
* Get detail of client theme.
*
* @param string $key
* @return mixed
*/
theme_detail('name');
/**
* Check current page is $page.
*
* @param string $page
* @return bool
*/
ispage('your.route.name');
/**
* Minify StyleSheet
*
* @param string $css
* @return string
*/
minifyCSS(<<<EOF
body {
background-color: red;
}
EOF
);
/**
* Minify JavaScript
*
* @param string $javascript
* @return string
*/
minifyJS(<<<EOF
$(document).ready(() => {
console.log('Document is ready!');
});
EOF
);
@themeSetting('key.in.settings.json')
YES
@else
NO
@endif
@page('your.route.name')
current page is first page
@elsepage('your.second.route.name')
current page is second page
@else
unknown page
@endpage
/**
* Set caching for assets is enabled or disabled. (Recommended for production)
*/
\IsaEken\ThemeSystem\ThemeSystem::$cacheAssets = false;
/**
* Set compress assets is enabled or disabled. (If enabled check your assets running correctly!)
*/
\IsaEken\ThemeSystem\ThemeSystem::$compressAssets = false;