sitestructure

This commit is contained in:
2025-11-20 02:31:04 +01:00
parent 5ee3b9afab
commit 055f07a620
16 changed files with 617 additions and 387 deletions

44
src/functions.php Normal file
View File

@@ -0,0 +1,44 @@
<?php
/**
* Templating Loader
*
* Beispiel:
* tpl('header'); // structure/header.php
* tpl('hero', 'landing', 'main'); // landing/main/hero.php
* tpl('faq', 'landing', 'fakecheck'); // landing/fakecheck/faq.php
*/
function tpl(string $file, string $type = 'structure', string $site = 'main'): void
{
// Basisordner
$base = __DIR__ . '/../partials/';
// Erlaubte Typen & Sites
$allowedTypes = ['structure', 'landing'];
$allowedSites = ['main', 'fakecheck'];
// Validierung
if (!in_array($type, $allowedTypes)) {
$type = 'structure';
}
if (!in_array($site, $allowedSites)) {
$site = 'main';
}
// Zielpfad konstruieren
if ($type === 'landing') {
// landing -> landing/{site}/{file}.php
$path = $base . "landing/$site/$file.php";
} else {
// structure -> structure/{file}.php
$path = $base . "structure/$file.php";
}
// Datei laden
if (file_exists($path)) {
include $path;
} else {
echo "<!-- tpl(): Datei nicht gefunden: $path -->";
}
}