| Install | |
|---|---|
composer require iamgerwin/filament-page-manager |
|
| Latest Version: | v1.0.3 |
| PHP: | ^8.3 |
A comprehensive page management system for Filament v4 with advanced features including template-based content management, regions, multilingual support, SEO optimization, and hierarchical page structures.
You can install the package via composer:
composer require iamgerwin/filament-page-manager
Register the plugin in your Panel provider (e.g., app/Providers/Filament/AdminPanelProvider.php):
use IamGerwin\FilamentPageManager\FilamentPageManagerPlugin;
public function panel(Panel $panel): Panel
{
return $panel
// ... other configuration
->plugins([
FilamentPageManagerPlugin::make(),
]);
}
You can publish and run the migrations with:
php artisan vendor:publish --tag="filament-page-manager-migrations"
php artisan migrate
You can publish the config file with:
php artisan vendor:publish --tag="filament-page-manager-config"
Optionally, you can publish the views using
php artisan vendor:publish --tag="filament-page-manager-views"
The configuration file config/filament-page-manager.php allows you to customize:
return [
'tables' => [
'pages' => 'fpm_pages',
'regions' => 'fpm_regions',
],
'locales' => [
'en' => 'English',
'es' => 'Spanish',
'fr' => 'French',
],
'default_locale' => 'en',
'seo' => [
'enabled' => true,
'fields' => [
'title' => ['label' => 'SEO Title', 'maxLength' => 60],
'description' => ['label' => 'SEO Description', 'maxLength' => 160],
],
],
];
Create a new page template:
php artisan filament-page-manager:make-template HomePage --type=page
This generates a template class in app/PageTemplates/HomePageTemplate.php:
<?php
namespace App\PageTemplates;
use Filament\Forms\Components\RichEditor;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\TextInput;
use IamGerwin\FilamentPageManager\Templates\AbstractPageTemplate;
class HomePageTemplate extends AbstractPageTemplate
{
public function name(): string
{
return 'Home Page';
}
public function fields(): array
{
return [
Section::make('Hero Section')
->schema([
TextInput::make('hero_title')
->label('Hero Title')
->required()
->maxLength(255),
RichEditor::make('hero_content')
->label('Hero Content')
->required(),
]),
];
}
public function pathSuffix(): ?string
{
return null; // or '.html' for specific URL patterns
}
}
Create a region template:
php artisan filament-page-manager:make-template Footer --type=region
<?php
namespace App\RegionTemplates;
use Filament\Forms\Components\Repeater;
use Filament\Forms\Components\TextInput;
use IamGerwin\FilamentPageManager\Templates\AbstractRegionTemplate;
class FooterTemplate extends AbstractRegionTemplate
{
public function name(): string
{
return 'Footer';
}
public function fields(): array
{
return [
TextInput::make('copyright')
->label('Copyright Text')
->required(),
Repeater::make('links')
->label('Footer Links')
->schema([
TextInput::make('title')->required(),
TextInput::make('url')->url()->required(),
])
->columns(2),
];
}
}
Register your templates in the configuration file:
'templates' => [
App\PageTemplates\HomePageTemplate::class,
App\PageTemplates\AboutPageTemplate::class,
App\PageTemplates\ContactPageTemplate::class,
App\RegionTemplates\HeaderTemplate::class,
App\RegionTemplates\FooterTemplate::class,
],
use IamGerwin\FilamentPageManager\Facades\FilamentPageManager;
// Get all published pages
$pages = FilamentPageManager::getPages();
// Get pages by template
$blogPages = FilamentPageManager::getPages([BlogPageTemplate::class]);
// Get page by slug
$page = FilamentPageManager::getPageBySlug('about-us', 'en');
// Get hierarchical page structure
$structure = FilamentPageManager::getPagesStructure();
// Get formatted page data for frontend
$pageData = FilamentPageManager::formatPage($page, 'en');
// Get page by slug
$page = fpm_get_page_by_slug('about-us');
// Get pages structure
$structure = fpm_get_pages_structure();
// Get region by name
$footer = fpm_get_region('footer');
// Format data for frontend
$formatted = fpm_format_page($page);
// Get all regions
$regions = FilamentPageManager::getRegions();
// Get region by name
$header = FilamentPageManager::getRegionByName('header');
// Format region data
$headerData = FilamentPageManager::formatRegion($header, 'en');
@php
$page = fpm_get_page_by_slug(request()->path());
$header = fpm_get_region('header');
@endphp
<!DOCTYPE html>
<html lang="{{ app()->getLocale() }}">
<head>
<title>{{ $page->seo['title'] ?? $page->name }}</title>
<meta name="description" content="{{ $page->seo['description'] ?? '' }}">
</head>
<body>
@if($header)
<header>
{!! $header->data['content'] !!}
</header>
@endif
<main>
<h1>{{ $page->data['title'] }}</h1>
{!! $page->data['content'] !!}
</main>
</body>
</html>
Configure multiple locales in your config:
'locales' => [
'en' => 'English',
'es' => 'Spanish',
'fr' => 'French',
'de' => 'German',
],
Access translated content:
$page->getTranslation('slug', 'es');
$page->setTranslation('data', 'fr', ['title' => 'Titre Français']);
Extend the base models for custom functionality:
namespace App\Models;
use IamGerwin\FilamentPageManager\Models\Page as BasePage;
class Page extends BasePage
{
public function generateMetaTags(): string
{
// Custom meta tag generation
}
}
Update configuration:
'models' => [
'page' => App\Models\Page::class,
],
The package includes intelligent caching:
// Clear all caches
FilamentPageManager::clearCache();
// Or using helper
fpm_clear_cache();
Configure cache settings:
'cache' => [
'enabled' => true,
'ttl' => 3600, // 1 hour
'tags' => ['filament-page-manager'],
],
composer test
This package maintains high code quality standards:
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security-related issues, please email iamgerwin@live.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.