Enhance placeholder functionality: Updated TemplateService to support 'setting' placeholders, allowing dynamic retrieval of settings values. Modified the placeholder picker to include setting types and added localization for new placeholder types in both English and Turkish. Improved site layout by integrating settings for favicon and custom CSS.
This commit is contained in:
@@ -384,6 +384,22 @@ class TemplateService
|
||||
|
||||
// Replace each placeholder
|
||||
foreach ($placeholders as $placeholder) {
|
||||
// Extract type from placeholder
|
||||
$parts = explode('.', $placeholder);
|
||||
$type = $parts[0] ?? null;
|
||||
$field = $parts[1] ?? null;
|
||||
|
||||
// Handle setting.* placeholders - get value from Setting model
|
||||
if ($type === 'setting' && $field) {
|
||||
$value = setting($field, '');
|
||||
|
||||
// Get setting type to determine if it's a file/image
|
||||
$settingModel = \App\Models\Setting::where('key', $field)->where('is_active', true)->first();
|
||||
if ($settingModel && in_array($settingModel->type, ['file', 'image'])) {
|
||||
// For file/image settings, use file type for formatting
|
||||
$type = 'file';
|
||||
}
|
||||
} else {
|
||||
// Try to find the value in data with various key formats
|
||||
$value = null;
|
||||
|
||||
@@ -397,7 +413,6 @@ class TemplateService
|
||||
}
|
||||
// 3. Try nested array access (data['section_data']['text.title'] or data['text']['title'])
|
||||
else {
|
||||
$parts = explode('.', $placeholder);
|
||||
if (count($parts) === 2) {
|
||||
[$type, $field] = $parts;
|
||||
// Try nested: data['section_data'][$type][$field]
|
||||
@@ -410,10 +425,7 @@ class TemplateService
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Extract type from placeholder to determine if it's a file/image
|
||||
$parts = explode('.', $placeholder);
|
||||
$type = $parts[0] ?? null;
|
||||
}
|
||||
|
||||
// Handle different value types
|
||||
if (is_array($value)) {
|
||||
|
||||
@@ -32,6 +32,7 @@ return [
|
||||
'type_toggle' => 'Toggle',
|
||||
'type_color' => 'Color',
|
||||
'type_tags' => 'Tags',
|
||||
'type_setting' => 'Setting',
|
||||
'type_custom' => 'Custom',
|
||||
];
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ return [
|
||||
'type_toggle' => 'Aç/Kapa',
|
||||
'type_color' => 'Renk',
|
||||
'type_tags' => 'Etiketler',
|
||||
'type_setting' => 'Ayar',
|
||||
'type_custom' => 'Özel',
|
||||
];
|
||||
|
||||
|
||||
@@ -1,7 +1,20 @@
|
||||
@php
|
||||
// Setting key'lerini veritabanından al (aktif ve public olanlar)
|
||||
$settingKeys = \App\Models\Setting::where('is_active', true)
|
||||
->where('is_public', true)
|
||||
->orderBy('key')
|
||||
->pluck('key')
|
||||
->toArray();
|
||||
|
||||
// Eğer setting yoksa, yaygın örnekleri kullan
|
||||
if (empty($settingKeys)) {
|
||||
$settingKeys = ['site_name', 'site_description', 'contact_email', 'contact_phone', 'site_url', 'copyright_text', 'seo_meta_title', 'seo_meta_description'];
|
||||
}
|
||||
|
||||
// Desteklenen placeholder tipleri ve açıklamaları
|
||||
$placeholderTypes = [
|
||||
'special' => ['label' => __('placeholder-picker.special_placeholders'), 'examples' => ['page.content', 'page.title', 'page.excerpt', 'menu', 'staticMenu']],
|
||||
'setting' => ['label' => __('placeholder-picker.type_setting'), 'examples' => array_slice($settingKeys, 0, 15)], // İlk 15 setting'i göster
|
||||
'text' => ['label' => __('placeholder-picker.type_text'), 'examples' => ['company_name', 'title', 'description', 'subtitle']],
|
||||
'email' => ['label' => __('placeholder-picker.type_email'), 'examples' => ['contact', 'support', 'info', 'sales']],
|
||||
'url' => ['label' => __('placeholder-picker.type_url'), 'examples' => ['website', 'facebook', 'twitter', 'linkedin']],
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
<?php
|
||||
|
||||
$favicon_path = setting('site_favicon');
|
||||
?>
|
||||
<!doctype html>
|
||||
<html lang="{{ app()->getLocale() }}">
|
||||
<head>
|
||||
@@ -5,15 +9,17 @@
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>{{ setting('seo_meta_title') }} - {{ $meta['title'] ?? ($settings->default_meta_title ?? config('app.name')) }}</title>
|
||||
<meta name="description" content="{{ $meta['description'] ?? ($settings->default_meta_description ?? '') }}">
|
||||
<link rel="icon" href="{{ $settings?->favicon_path ? asset($settings->favicon_path) : asset('assets/img/favicon.ico') }}">
|
||||
<meta name="description" content="{{ $meta['description'] ?? (setting('seo_meta_description') ?? '') }}">
|
||||
<link rel="icon" href="{{ asset('storage/' . $favicon_path) }}">
|
||||
<link rel="stylesheet" href="{{ asset('html/style.css') }}">
|
||||
<link rel="stylesheet" type="text/css" href="{{ asset('assets/fonts/unicons/unicons.css') }}">
|
||||
<link rel="stylesheet" href="{{ asset('assets/css/plugins.css') }}">
|
||||
<link rel="stylesheet" href="{{ asset('assets/css/colors/grape.css') }}">
|
||||
<link rel="preload" href="{{ asset('assets/css/fonts/urbanist.css') }}" as="style" onload="this.rel='stylesheet'">
|
||||
|
||||
|
||||
<style>
|
||||
<?php echo setting('custom_css') ?>
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
Reference in New Issue
Block a user