Enhance Template Import and Preview Functionality: Updated the ImportHtmlTemplates command to improve asset path handling by moving files to storage and updating HTML asset paths. Added a preview action in SectionTemplatesTable for better template management, along with a new Blade view for rendering previews. Adjusted route for template preview to accept any request method for flexibility.

This commit is contained in:
Ümit Tunç
2025-12-27 09:38:38 +03:00
parent 70cba75441
commit f609eb3ec1
5 changed files with 67 additions and 2 deletions
+7 -1
View File
@@ -314,8 +314,9 @@ class TemplateService
* @param string $html HTML content with placeholders
* @param array $data Data array for placeholders
* @param Model|null $model Optional model instance (Page, Blog, etc.) for dynamic data
* @param array $defaultData Optional default data for fallback
*/
public static function replacePlaceholders(string $html, array $data, ?Model $model = null): string
public static function replacePlaceholders(string $html, array $data, ?Model $model = null, array $defaultData = []): string
{
// Handle special {page.content} placeholder - Sayfa/model içeriğini gösterir
if (str_contains($html, '{page.content}')) {
@@ -564,6 +565,11 @@ class TemplateService
}
}
// 5. Fallback to default data
if (($value === null || $value === '') && isset($defaultData[$placeholder])) {
$value = $defaultData[$placeholder];
}
// Handle different value types
if (is_array($value)) {
// Handle arrays (e.g., multiple images)