Installation Add the theme to your Laravel-based CVEPDB CMS project via Composer:
composer require cvepdb-cms/theme-flatly
Publish the theme assets (if needed):
php artisan vendor:publish --tag=flatly-theme-assets
Enable the Theme
Configure the theme in config/cms.php under the themes section:
'default' => 'flatly',
'available' => [
'flatly' => [
'name' => 'Flatly',
'path' => 'vendor/cvepdb-cms/theme-flatly',
],
],
First Use Case
resources/views/vendor/cvepdb (e.g., resources/views/vendor/cvepdb/layouts/app.blade.php).app.blade.php or a service provider:
@vite(['resources/css/app.css', 'resources/js/app.js']) <!-- If using Vite -->
<!-- OR -->
<link href="{{ asset('vendor/flatly/css/bootstrap.min.css') }}" rel="stylesheet">
app.blade.php (or similar) in its resources/views/layouts directory. Override it in your project’s resources/views/vendor/cvepdb/layouts/ to customize:
@extends('vendor.cvepdb.layouts.app') <!-- Extend theme's layout -->
@section('title', 'Custom Title')
php artisan vendor:publish --tag=flatly-theme-views
resources/sass/custom.scss:
@import 'vendor/flatly/scss/bootstrap';
$theme-colors: (
'primary': #3498db,
'danger': #e74c3c
);
// app/Http/Middleware/SwitchTheme.php
public function handle($request, Closure $next) {
if ($request->user()->prefers_dark_mode) {
config(['cms.themes.default' => 'flatly-dark']);
}
return $next($request);
}
// Example: Load theme assets via API
$themeAssets = Theme::find(config('cms.themes.default'))->assets;
resources/js/flatly.js and include them in app.blade.php:
@push('scripts')
<script src="{{ asset('js/flatly.js') }}"></script>
@endpush
document.addEventListener('DOMContentLoaded', function() {
// Custom Flatly behavior
new bootstrap.Modal(document.getElementById('customModal'));
});
Asset Paths
/vendor/flatly/...) may break when publishing assets.mix() or asset() helper:
<link href="{{ mix('vendor/flatly/css/bootstrap.min.css') }}" rel="stylesheet">
Theme Conflicts
php artisan vendor:publish --tag=flatly-theme-views --force
Bootstrap Version Mismatch
package.json or use a CDN with a specific version.Caching Headaches
php artisan view:clear
php artisan cache:clear
npm run dev # or `npm run build` for production
storage/framework/views for compiled theme views.app/Providers/ThemeServiceProvider.php to track theme initialization:
Log::debug('Active theme:', config('cms.themes.default'));
Custom Theme Config
Extend the theme’s config in config/cms.php:
'themes' => [
'flatly' => [
'custom' => [
'header_logo' => asset('images/custom-logo.png'),
],
],
],
Access it in views:
<img src="{{ config('cms.themes.flatly.custom.header_logo') }}" alt="Logo">
Dynamic Theme Assets Load theme assets conditionally based on user preferences:
// In a Blade view
@if (config('cms.themes.default') === 'flatly')
<link href="{{ asset('vendor/flatly/css/flatly-extensions.css') }}" rel="stylesheet">
@endif
Theme-Specific Middleware Restrict access or modify behavior per theme:
// app/Http/Kernel.php
'web' => [
\App\Http\Middleware\FlatlyThemeMiddleware::class,
// ...
],
// app/Http/Middleware/FlatlyThemeMiddleware.php
public function handle($request, Closure $next) {
if (config('cms.themes.default') === 'flatly') {
// Custom logic for Flatly theme
}
return $next($request);
}
Dark Mode Support If the theme supports dark mode, toggle it via JavaScript or user settings:
// Toggle dark mode
document.querySelector('#dark-mode-toggle').addEventListener('click', () => {
document.body.classList.toggle('dark-mode');
localStorage.setItem('darkMode', document.body.classList.contains('dark-mode'));
});
How can I help you explore Laravel packages today?