Enhance Template Preview Functionality: Added a preview action to both HeaderTemplatesTable and FooterTemplatesTable, allowing users to preview templates in a modal. Updated localization files to include preview action labels in both English and Turkish. Introduced new Blade views for rendering template previews, improving the overall user experience in template management.

This commit is contained in:
Ümit Tunç
2025-12-27 09:50:38 +03:00
parent 537e2769cd
commit f4603456b1
9 changed files with 48 additions and 8 deletions
+6 -8
View File
@@ -290,14 +290,12 @@ class ImportHtmlTemplates extends Command
// DOMDocument attribute değerlerini encode ettiği için bunları geri çeviriyoruz
$html = str_replace(['%7B', '%7D'], ['{', '}'], $html);
// SPECIAL TOKENS FIX
if ($templateType === 'header') {
$html = str_replace('___SPECIAL_MENU___', '{custom.menu}', $html); // Geriye dönük uyumluluk
$html = str_replace('___CUSTOM_MENU___', '{custom.menu}', $html);
$html = str_replace('___CUSTOM_NAVBAR___', '{custom.navbar}', $html);
$html = str_replace('___CUSTOM_LANGUAGE___', '{custom.language-selector}', $html);
$html = str_replace('___SETTING_LANGUAGES___', '{custom.language-selector}', $html);
}
// SPECIAL TOKENS FIX - Replace placeholder tokens with actual template syntax
$html = str_replace('___SPECIAL_MENU___', '{custom.menu}', $html);
$html = str_replace('___CUSTOM_MENU___', '{custom.menu}', $html);
$html = str_replace('___CUSTOM_NAVBAR___', '{custom.navbar}', $html);
$html = str_replace('___CUSTOM_LANGUAGE___', '{custom.language-selector}', $html);
$html = str_replace('___SETTING_LANGUAGES___', '{custom.language-selector}', $html);
return ['html' => $html, 'data' => $data];
}
@@ -12,6 +12,7 @@ use Filament\Tables\Columns\IconColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Filters\TrashedFilter;
use Filament\Tables\Table;
use Filament\Actions\Action;
class FooterTemplatesTable
{
@@ -56,6 +57,13 @@ class FooterTemplatesTable
TrashedFilter::make(),
])
->recordActions([
Action::make('preview')
->label(__('footer-templates.action_preview'))
->icon('heroicon-o-eye')
->modalContent(fn ($record) => view('filament.admin.resources.footer-templates.preview', ['record' => $record]))
->modalSubmitAction(false)
->modalCancelAction(false)
->modalWidth('7xl'),
ViewAction::make(),
EditAction::make(),
])
@@ -12,6 +12,7 @@ use Filament\Tables\Columns\IconColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Filters\TrashedFilter;
use Filament\Tables\Table;
use Filament\Actions\Action;
class HeaderTemplatesTable
{
@@ -56,6 +57,13 @@ class HeaderTemplatesTable
TrashedFilter::make(),
])
->recordActions([
Action::make('preview')
->label(__('header-templates.action_preview'))
->icon('heroicon-o-eye')
->modalContent(fn ($record) => view('filament.admin.resources.header-templates.preview', ['record' => $record]))
->modalSubmitAction(false)
->modalCancelAction(false)
->modalWidth('7xl'),
ViewAction::make(),
EditAction::make(),
])
+1
View File
@@ -27,6 +27,7 @@ return [
'column_deleted_at' => 'Deleted At',
// Actions
'action_preview' => 'Preview',
'create' => 'New Footer Template',
'edit' => 'Edit Footer Template',
'view' => 'View Footer Template',
+1
View File
@@ -27,6 +27,7 @@ return [
'column_deleted_at' => 'Deleted At',
// Actions
'action_preview' => 'Preview',
'create' => 'New Header Template',
'edit' => 'Edit Header Template',
'view' => 'View Header Template',
+1
View File
@@ -27,6 +27,7 @@ return [
'column_deleted_at' => 'Silinme',
// Actions
'action_preview' => 'Önizleme',
'create' => 'Yeni Footer Şablonu',
'edit' => 'Footer Şablonunu Düzenle',
'view' => 'Footer Şablonunu Görüntüle',
+1
View File
@@ -27,6 +27,7 @@ return [
'column_deleted_at' => 'Silinme',
// Actions
'action_preview' => 'Önizleme',
'create' => 'Yeni Header Şablonu',
'edit' => 'Header Şablonunu Düzenle',
'view' => 'Header Şablonunu Görüntüle',
@@ -0,0 +1,11 @@
<div class="w-full flex flex-col" style="height: 600px;">
<div class="flex-1 w-full relative bg-white border rounded-lg overflow-hidden">
<iframe
src="{{ route('template.preview', ['type' => 'footer', 'record_id' => $record->id]) }}"
class="w-full h-full absolute inset-0 border-0"
style="width: 100%; height: 100%;"
title="Preview"
></iframe>
</div>
</div>
@@ -0,0 +1,11 @@
<div class="w-full flex flex-col" style="height: 600px;">
<div class="flex-1 w-full relative bg-white border rounded-lg overflow-hidden">
<iframe
src="{{ route('template.preview', ['type' => 'header', 'record_id' => $record->id]) }}"
class="w-full h-full absolute inset-0 border-0"
style="width: 100%; height: 100%;"
title="Preview"
></iframe>
</div>
</div>