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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user