diff --git a/app/Console/Commands/ImportHtmlTemplates.php b/app/Console/Commands/ImportHtmlTemplates.php index e68ee9f..d64058d 100644 --- a/app/Console/Commands/ImportHtmlTemplates.php +++ b/app/Console/Commands/ImportHtmlTemplates.php @@ -268,8 +268,8 @@ class ImportHtmlTemplates extends Command if (in_array(strtolower($parent->nodeName), ['script', 'style', 'noscript', 'iframe'])) continue; $textContent = trim($textNode->textContent); - // Özel tokenlarımızı atla - if (str_contains($textContent, '___SPECIAL_') || str_contains($textContent, '___SETTING_')) continue; + // Özel tokenlarımızı atla (___SPECIAL_, ___SETTING_, ___CUSTOM_) + if (str_contains($textContent, '___SPECIAL_') || str_contains($textContent, '___SETTING_') || str_contains($textContent, '___CUSTOM_')) continue; if (str_starts_with($textContent, '{') && str_ends_with($textContent, '}')) continue; if (mb_strlen($textContent) < 2) continue; @@ -297,6 +297,17 @@ class ImportHtmlTemplates extends Command $html = str_replace('___CUSTOM_LANGUAGE___', '{custom.language-selector}', $html); $html = str_replace('___SETTING_LANGUAGES___', '{custom.language-selector}', $html); + // Clean default_data from any leftover tokens + foreach ($data as $key => $value) { + if (is_string($value) && ( + str_contains($value, '___CUSTOM_') || + str_contains($value, '___SPECIAL_') || + str_contains($value, '___SETTING_') + )) { + unset($data[$key]); + } + } + return ['html' => $html, 'data' => $data]; } diff --git a/app/Services/TemplateService.php b/app/Services/TemplateService.php index b703149..3226bf9 100644 --- a/app/Services/TemplateService.php +++ b/app/Services/TemplateService.php @@ -318,6 +318,14 @@ class TemplateService */ public static function replacePlaceholders(string $html, array $data, ?Model $model = null, array $defaultData = []): string { + // Legacy/Import artifact fix: Replace ___CUSTOM_...___ tokens if they exist in DB + // These tokens might be leftover from import process if str_replace didn't catch them + $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); + // Handle special {page.content} placeholder - Sayfa/model içeriğini gösterir if (str_contains($html, '{page.content}')) { $pageContent = '';