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,37 +384,49 @@ class TemplateService
|
|||||||
|
|
||||||
// Replace each placeholder
|
// Replace each placeholder
|
||||||
foreach ($placeholders as $placeholder) {
|
foreach ($placeholders as $placeholder) {
|
||||||
// Try to find the value in data with various key formats
|
// Extract type from placeholder
|
||||||
$value = null;
|
$parts = explode('.', $placeholder);
|
||||||
|
$type = $parts[0] ?? null;
|
||||||
|
$field = $parts[1] ?? null;
|
||||||
|
|
||||||
// 1. Try exact match (text.title)
|
// Handle setting.* placeholders - get value from Setting model
|
||||||
if (isset($data[$placeholder])) {
|
if ($type === 'setting' && $field) {
|
||||||
$value = $data[$placeholder];
|
$value = setting($field, '');
|
||||||
}
|
|
||||||
// 2. Try with section_data prefix (section_data.text.title)
|
// Get setting type to determine if it's a file/image
|
||||||
elseif (isset($data["section_data.{$placeholder}"])) {
|
$settingModel = \App\Models\Setting::where('key', $field)->where('is_active', true)->first();
|
||||||
$value = $data["section_data.{$placeholder}"];
|
if ($settingModel && in_array($settingModel->type, ['file', 'image'])) {
|
||||||
}
|
// For file/image settings, use file type for formatting
|
||||||
// 3. Try nested array access (data['section_data']['text.title'] or data['text']['title'])
|
$type = 'file';
|
||||||
else {
|
}
|
||||||
$parts = explode('.', $placeholder);
|
} else {
|
||||||
if (count($parts) === 2) {
|
// Try to find the value in data with various key formats
|
||||||
[$type, $field] = $parts;
|
$value = null;
|
||||||
// Try nested: data['section_data'][$type][$field]
|
|
||||||
if (isset($data['section_data'][$type][$field])) {
|
// 1. Try exact match (text.title)
|
||||||
$value = $data['section_data'][$type][$field];
|
if (isset($data[$placeholder])) {
|
||||||
}
|
$value = $data[$placeholder];
|
||||||
// Try nested: data[$type][$field]
|
}
|
||||||
elseif (isset($data[$type][$field])) {
|
// 2. Try with section_data prefix (section_data.text.title)
|
||||||
$value = $data[$type][$field];
|
elseif (isset($data["section_data.{$placeholder}"])) {
|
||||||
|
$value = $data["section_data.{$placeholder}"];
|
||||||
|
}
|
||||||
|
// 3. Try nested array access (data['section_data']['text.title'] or data['text']['title'])
|
||||||
|
else {
|
||||||
|
if (count($parts) === 2) {
|
||||||
|
[$type, $field] = $parts;
|
||||||
|
// Try nested: data['section_data'][$type][$field]
|
||||||
|
if (isset($data['section_data'][$type][$field])) {
|
||||||
|
$value = $data['section_data'][$type][$field];
|
||||||
|
}
|
||||||
|
// Try nested: data[$type][$field]
|
||||||
|
elseif (isset($data[$type][$field])) {
|
||||||
|
$value = $data[$type][$field];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract type from placeholder to determine if it's a file/image
|
|
||||||
$parts = explode('.', $placeholder);
|
|
||||||
$type = $parts[0] ?? null;
|
|
||||||
|
|
||||||
// Handle different value types
|
// Handle different value types
|
||||||
if (is_array($value)) {
|
if (is_array($value)) {
|
||||||
// Handle arrays (e.g., multiple images)
|
// Handle arrays (e.g., multiple images)
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ return [
|
|||||||
'type_toggle' => 'Toggle',
|
'type_toggle' => 'Toggle',
|
||||||
'type_color' => 'Color',
|
'type_color' => 'Color',
|
||||||
'type_tags' => 'Tags',
|
'type_tags' => 'Tags',
|
||||||
|
'type_setting' => 'Setting',
|
||||||
'type_custom' => 'Custom',
|
'type_custom' => 'Custom',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ return [
|
|||||||
'type_toggle' => 'Aç/Kapa',
|
'type_toggle' => 'Aç/Kapa',
|
||||||
'type_color' => 'Renk',
|
'type_color' => 'Renk',
|
||||||
'type_tags' => 'Etiketler',
|
'type_tags' => 'Etiketler',
|
||||||
|
'type_setting' => 'Ayar',
|
||||||
'type_custom' => 'Özel',
|
'type_custom' => 'Özel',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,20 @@
|
|||||||
@php
|
@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ı
|
// Desteklenen placeholder tipleri ve açıklamaları
|
||||||
$placeholderTypes = [
|
$placeholderTypes = [
|
||||||
'special' => ['label' => __('placeholder-picker.special_placeholders'), 'examples' => ['page.content', 'page.title', 'page.excerpt', 'menu', 'staticMenu']],
|
'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']],
|
'text' => ['label' => __('placeholder-picker.type_text'), 'examples' => ['company_name', 'title', 'description', 'subtitle']],
|
||||||
'email' => ['label' => __('placeholder-picker.type_email'), 'examples' => ['contact', 'support', 'info', 'sales']],
|
'email' => ['label' => __('placeholder-picker.type_email'), 'examples' => ['contact', 'support', 'info', 'sales']],
|
||||||
'url' => ['label' => __('placeholder-picker.type_url'), 'examples' => ['website', 'facebook', 'twitter', 'linkedin']],
|
'url' => ['label' => __('placeholder-picker.type_url'), 'examples' => ['website', 'facebook', 'twitter', 'linkedin']],
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$favicon_path = setting('site_favicon');
|
||||||
|
?>
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="{{ app()->getLocale() }}">
|
<html lang="{{ app()->getLocale() }}">
|
||||||
<head>
|
<head>
|
||||||
@@ -5,15 +9,17 @@
|
|||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<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>
|
<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 ?? '') }}">
|
<meta name="description" content="{{ $meta['description'] ?? (setting('seo_meta_description') ?? '') }}">
|
||||||
<link rel="icon" href="{{ $settings?->favicon_path ? asset($settings->favicon_path) : asset('assets/img/favicon.ico') }}">
|
<link rel="icon" href="{{ asset('storage/' . $favicon_path) }}">
|
||||||
<link rel="stylesheet" href="{{ asset('html/style.css') }}">
|
<link rel="stylesheet" href="{{ asset('html/style.css') }}">
|
||||||
<link rel="stylesheet" type="text/css" href="{{ asset('assets/fonts/unicons/unicons.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/plugins.css') }}">
|
||||||
<link rel="stylesheet" href="{{ asset('assets/css/colors/grape.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'">
|
<link rel="preload" href="{{ asset('assets/css/fonts/urbanist.css') }}" as="style" onload="this.rel='stylesheet'">
|
||||||
|
|
||||||
|
<style>
|
||||||
|
<?php echo setting('custom_css') ?>
|
||||||
|
</style>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
Reference in New Issue
Block a user