Implement dynamic template rendering and page observer: Enhanced PageController to support dynamic header and footer templates, utilizing TemplateService for placeholder replacement. Introduced PageObserver to manage homepage status across pages. Updated routes for improved debugging and dynamic homepage display. Refactored views to accommodate new templating system.

This commit is contained in:
Ümit Tunç
2025-10-31 15:49:29 -03:00
parent 2380e9cc39
commit 02e4f46694
9 changed files with 259 additions and 37 deletions
+15 -2
View File
@@ -9,9 +9,22 @@
<link rel="stylesheet" href="{{ asset('html/style.css') }}">
</head>
<body>
@include('partials.navbar')
{{-- Dynamic Header Template or Static Navbar --}}
@if(isset($renderedHeader) && $renderedHeader)
{!! $renderedHeader !!}
@else
@include('partials.navbar')
@endif
{{-- Main Content --}}
@yield('content')
@include('partials.footer')
{{-- Dynamic Footer Template or Static Footer --}}
@if(isset($renderedFooter) && $renderedFooter)
{!! $renderedFooter !!}
@else
@include('partials.footer')
@endif
{{-- İsteğe bağlı: tema JS dosyalarınız varsa buraya ekleyin --}}
{{-- <script src="{{ asset('assets/js/main.js') }}" defer></script> --}}
+21 -2
View File
@@ -1,8 +1,27 @@
@extends('layouts.site')
@section('content')
@php $blocks = $sections ?? []; @endphp
@if(is_array($blocks) && !empty($blocks))
@php
// Yeni dinamik template sistemi - Öncelik verilir
$hasTemplatedSections = isset($templatedSections) && $templatedSections->isNotEmpty();
// Eski section builder sistemi
$blocks = $sections ?? [];
$hasBlocks = is_array($blocks) && !empty($blocks);
@endphp
@if($hasTemplatedSections)
{{-- Yeni dinamik template sisteminden gelen sections --}}
@foreach($templatedSections as $section)
@if($section['template'] ?? null)
{!! \App\Services\TemplateService::replacePlaceholders(
$section['template']->html_content,
$section['data'] ?? []
) !!}
@endif
@endforeach
@elseif($hasBlocks)
{{-- Eski blok bazlı dinamik render --}}
@foreach($blocks as $block)
@php $type = $block['type'] ?? null; @endphp
@if($type && view()->exists("components.blocks.$type"))
+16 -3
View File
@@ -2,13 +2,26 @@
@section('content')
@php
// sections varsa blok bazlı render, yoksa index.html fallback
// Yeni dinamik template sistemi - Öncelik verilir
$hasTemplatedSections = isset($templatedSections) && $templatedSections->isNotEmpty();
// Eski section builder sistemi
$blocks = $sections ?? [];
$hasBlocks = is_array($blocks) && count($blocks) > 0;
@endphp
@if($hasBlocks)
{{-- Blok bazlı dinamik render --}}
@if($hasTemplatedSections)
{{-- Yeni dinamik template sisteminden gelen sections --}}
@foreach($templatedSections as $section)
@if($section['template'] ?? null)
{!! \App\Services\TemplateService::replacePlaceholders(
$section['template']->html_content,
$section['data'] ?? []
) !!}
@endif
@endforeach
@elseif($hasBlocks)
{{-- Eski blok bazlı dinamik render --}}
@foreach($blocks as $block)
@php $type = $block['type'] ?? null; @endphp
@if($type && view()->exists("components.blocks.$type"))