{{-- Frontend Renderer for Post Template Pages (Builder V2) Used for dynamic post detail pages with templates --}} @php \Log::info('==================== TEMPLATES RENDER-V2 START ===================='); // Load shared render functions require_once app_path('Helpers/builder_v2_helpers.php'); // Templates use $template and $builderData variables // dynamicData contains post-specific data to inject $rootNode = $builderData['ROOT'] ?? null; // Get website and its settings $currentWebsite = $template->website ?? null; $currentWebsiteId = $template->website_id ?? null; $currencySymbol = $currentWebsite ? $currentWebsite->getCurrencySymbol() : 'RM'; $websiteSubdomain = $currentWebsite ? $currentWebsite->subdomain : null; // Get theme's default preset for font scheme $themeFonts = ['heading' => 'Inter', 'body' => 'Inter']; // Default fallback if ($currentWebsite) { $activeTheme = $currentWebsite->activeTheme; if ($activeTheme && $activeTheme->theme) { $defaultPreset = $activeTheme->theme->presets()->where('is_default', true)->first(); if ($defaultPreset && isset($defaultPreset->font_scheme)) { $themeFonts = [ 'heading' => $defaultPreset->font_scheme['heading'] ?? 'Inter', 'body' => $defaultPreset->font_scheme['body'] ?? 'Inter', ]; \Log::info('Theme fonts loaded', $themeFonts); } } } @endphp @if($rootNode && isset($builderData)) @php $rootType = $rootNode['type']['resolvedName'] ?? null; $rootProps = $rootNode['props'] ?? []; $rootChildren = $rootNode['nodes'] ?? []; @endphp @if($rootType === 'Container') @php $width = $rootProps['width'] ?? 'fluid'; $customWidth = $rootProps['customWidth'] ?? '1140px'; $padding = $rootProps['padding'] ?? '20px'; $margin = $rootProps['margin'] ?? '0px'; $backgroundColor = $rootProps['backgroundColor'] ?? 'transparent'; $containerClass = $width === 'fluid' ? 'container-fluid' : 'container'; $styles = []; $styles[] = 'padding: ' . htmlspecialchars($padding); if ($width === 'fixed') { $margins = explode(' ', trim($margin)); if (count($margins) === 1) { $styles[] = 'margin: ' . htmlspecialchars($margins[0]) . ' auto'; } else if (count($margins) === 2) { $styles[] = 'margin: ' . htmlspecialchars($margins[0]) . ' auto'; } else if (count($margins) === 4) { $styles[] = 'margin: ' . htmlspecialchars($margins[0]) . ' auto ' . htmlspecialchars($margins[2]) . ' auto'; } else { $styles[] = 'margin-left: auto'; $styles[] = 'margin-right: auto'; } $styles[] = 'max-width: ' . htmlspecialchars($customWidth); } else { $styles[] = 'margin: ' . htmlspecialchars($margin); } if ($backgroundColor && $backgroundColor !== 'transparent') { $styles[] = 'background-color: ' . htmlspecialchars($backgroundColor); } $styleAttr = implode('; ', $styles); @endphp
@foreach($rootChildren as $nodeId) {!! renderNode($nodeId, $builderData, $currentWebsiteId, $currencySymbol, $websiteSubdomain, $themeFonts) !!} @endforeach
@else @foreach($rootChildren as $nodeId) {!! renderNode($nodeId, $builderData, $currentWebsiteId, $currencySymbol, $websiteSubdomain, $themeFonts) !!} @endforeach @endif @else
This template is empty.
@endif