refactor: unify template structure by introducing a layout snippet
Replaces repetitive header, navbar, and footer code in templates with a centralized `layout` snippet for better maintainability. Cleans up and simplifies various template snippets.
This commit is contained in:
@@ -1,17 +1,3 @@
|
||||
<?php
|
||||
/*
|
||||
Snippets are a great way to store code snippets for reuse
|
||||
or to keep your templates clean.
|
||||
|
||||
This footer snippet is reused in all templates.
|
||||
|
||||
More about snippets:
|
||||
https://getkirby.com/docs/guide/templates/snippets
|
||||
*/
|
||||
|
||||
?>
|
||||
<footer class="bg-sf_grau-400 w-full" data-pgc-define="footer"
|
||||
data-pgc-define-name="Footer">
|
||||
<div class="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8">
|
||||
<!--Grid-->
|
||||
<div class="py-16 flex justify-between items-center flex-col gap-8 lg:flex-row">
|
||||
@@ -132,12 +118,8 @@
|
||||
<!--Grid-->
|
||||
<div class="py-7 border-t border-gray-700">
|
||||
<div class="flex items-center justify-center">
|
||||
<span class="text-base text-sf_gray-700">© 2025 - <a
|
||||
<span class="text-base text-sf_gray-700">© <?= date('Y') ?> - <a
|
||||
href="https://www.schachfreunde-badsteben.de/">Schachfreunde Bad Steben </a></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
Snippets are a great way to store code snippets for reuse
|
||||
or to keep your templates clean.
|
||||
|
||||
This header snippet is reused in all templates.
|
||||
It fetches information from the `site.txt` content file
|
||||
and contains the site navigation.
|
||||
|
||||
More about snippets:
|
||||
https://getkirby.com/docs/guide/templates/snippets
|
||||
*/
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||
|
||||
<?php
|
||||
/*
|
||||
In the title tag we show the title of our
|
||||
site and the title of the current page
|
||||
*/
|
||||
|
||||
?>
|
||||
|
||||
<title><?= $site->title()->esc() ?> | <?= $page->title()->esc() ?></title>
|
||||
|
||||
<?php
|
||||
/*
|
||||
Stylesheets can be included using the `css()` helper.
|
||||
Kirby also provides the `js()` helper to include script file.
|
||||
More Kirby helpers: https://getkirby.com/docs/reference/templates/helpers
|
||||
*/
|
||||
|
||||
?>
|
||||
|
||||
<?= css([
|
||||
'assets/css/styles.css',
|
||||
'assets/css/png4web.css',
|
||||
]) ?>
|
||||
|
||||
<?php
|
||||
/*
|
||||
The `url()` helper is a great way to create reliable
|
||||
absolute URLs in Kirby that always start with the
|
||||
base URL of your site.
|
||||
*/
|
||||
|
||||
?>
|
||||
|
||||
<link rel="shortcut icon" type="image/x-icon"
|
||||
href="<?= url('assets/favicon.ico') ?>">
|
||||
</head>
|
||||
@@ -0,0 +1,45 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||
|
||||
<title><?= $site->title()->esc() ?> | <?= $page->title()->esc() ?></title>
|
||||
|
||||
<?= css([
|
||||
'assets/css/styles.css',
|
||||
'assets/css/png4web.css',
|
||||
]) ?>
|
||||
|
||||
<link rel="shortcut icon" type="image/x-icon"
|
||||
href="<?= url('assets/favicon.ico') ?>">
|
||||
</head>
|
||||
|
||||
<body class="font-sans antialiased bg-sf_grau-400 text-gray-900">
|
||||
<header>
|
||||
<?php snippet('navbar') ?>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
|
||||
<?php if ($page->isHomePage()): ?>
|
||||
<?php snippet('hero') ?>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if ($page->heroText()->isNotEmpty()): ?>
|
||||
<?php snippet('titel') ?>
|
||||
<?php endif ?>
|
||||
|
||||
<section class="py-24 bg-sf_grau-50">
|
||||
<div class="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8">
|
||||
<?= $slot ?>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<footer class="bg-sf_grau-400 w-full" id="footer">
|
||||
<?php snippet('footer') ?>
|
||||
</footer>
|
||||
<?= js('assets/js/navbar.js') ?>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,7 +1,4 @@
|
||||
<nav class="bg-sf_grau-50 shadow-lg sticky top-0 z-50" data-pgc-define="navbar"
|
||||
data-pgc-define-name="Navigationsleiste"
|
||||
data-pgc-define-description="Navigationsleiste zur Verwendung auf allen Seiten"
|
||||
data-pgc-define-photo-preview-only>
|
||||
<nav class="bg-sf_grau-50 shadow-lg sticky top-0 z-50">
|
||||
<div class="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8">
|
||||
<div class="flex h-24 items-center justify-between">
|
||||
<!-- Logo (Links) -->
|
||||
|
||||
@@ -6,9 +6,7 @@
|
||||
</div>
|
||||
<div class="w-full max-w-lg">
|
||||
<p class="lg:pt-0 pt-6 text-xl"><?= $page->heroText() ?></p>
|
||||
|
||||
<?php
|
||||
if ($page->heroButton()->isNotEmpty()): ?>
|
||||
<?php if ($page->heroButton()->isNotEmpty()): ?>
|
||||
<div class="mt-6 flex flex-wrap gap-4 md:mt-8">
|
||||
<a href="<?= $page->buttonLink() ?>" class="hover:cursor-pointer hover:text-sf_gelb-500"
|
||||
target="_blank">
|
||||
@@ -18,9 +16,7 @@
|
||||
</button>
|
||||
</a>
|
||||
</div>
|
||||
<?php
|
||||
endif ?>
|
||||
|
||||
<?php endif ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,36 +1,5 @@
|
||||
<?php
|
||||
/*
|
||||
Templates render the content of your pages.
|
||||
<?php snippet('layout', slots: true) ?>
|
||||
|
||||
They contain the markup together with some control structures
|
||||
like loops or if-statements. The `$page` variable always
|
||||
refers to the currently active page.
|
||||
<h1>Hallo Welt!</h1>
|
||||
|
||||
To fetch the content from each field we call the field name as a
|
||||
method on the `$page` object, e.g. `$page->title()`.
|
||||
|
||||
This default template must not be removed. It is used whenever Kirby
|
||||
cannot find a template with the name of the content file.
|
||||
|
||||
Snippets like the header and footer contain markup used in
|
||||
multiple templates. They also help to keep templates clean.
|
||||
|
||||
More about templates: https://getkirby.com/docs/guide/templates/basics
|
||||
*/
|
||||
|
||||
?>
|
||||
|
||||
<?php
|
||||
snippet('header') ?>
|
||||
|
||||
<body class="font-sans antialiased bg-sf_grau-400 text-gray-900">
|
||||
|
||||
<?php
|
||||
snippet('navbar') ?>
|
||||
|
||||
<?= js('assets/js/navbar.js') ?>
|
||||
|
||||
</body>
|
||||
|
||||
<?php
|
||||
snippet('footer') ?>
|
||||
<?php endsnippet() ?>
|
||||
+3
-37
@@ -1,39 +1,5 @@
|
||||
<?php
|
||||
/*
|
||||
Templates render the content of your pages.
|
||||
<?php snippet('layout', slots: true) ?>
|
||||
|
||||
They contain the markup together with some control structures
|
||||
like loops or if-statements. The `$page` variable always
|
||||
refers to the currently active page.
|
||||
<?php snippet('dwz') ?>
|
||||
|
||||
To fetch the content from each field we call the field name as a
|
||||
method on the `$page` object, e.g. `$page->title()`.
|
||||
|
||||
This default template must not be removed. It is used whenever Kirby
|
||||
cannot find a template with the name of the content file.
|
||||
|
||||
Snippets like the header and footer contain markup used in
|
||||
multiple templates. They also help to keep templates clean.
|
||||
|
||||
More about templates: https://getkirby.com/docs/guide/templates/basics
|
||||
*/
|
||||
|
||||
?>
|
||||
<?php
|
||||
snippet('header') ?>
|
||||
|
||||
<body>
|
||||
<?php
|
||||
snippet('navbar') ?>
|
||||
|
||||
<?php
|
||||
snippet('titel') ?>
|
||||
|
||||
<?php
|
||||
snippet('dwz') ?>
|
||||
|
||||
<?= js('assets/js/navbar.js') ?>
|
||||
</body>
|
||||
|
||||
<?php
|
||||
snippet('footer') ?>
|
||||
<?php endsnippet() ?>
|
||||
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
Templates render the content of your pages.
|
||||
|
||||
They contain the markup together with some control structures
|
||||
like loops or if-statements. The `$page` variable always
|
||||
refers to the currently active page.
|
||||
|
||||
To fetch the content from each field we call the field name as a
|
||||
method on the `$page` object, e.g. `$page->title()`.
|
||||
|
||||
This default template must not be removed. It is used whenever Kirby
|
||||
cannot find a template with the name of the content file.
|
||||
|
||||
Snippets like the header and footer contain markup used in
|
||||
multiple templates. They also help to keep templates clean.
|
||||
|
||||
More about templates: https://getkirby.com/docs/guide/templates/basics
|
||||
*/
|
||||
|
||||
?>
|
||||
<?php
|
||||
snippet('header') ?>
|
||||
|
||||
<body class="font-sans antialiased bg-sf_grau-400 text-gray-900">
|
||||
<?php
|
||||
snippet('navbar') ?>
|
||||
|
||||
<?php
|
||||
snippet('hero') ?>
|
||||
|
||||
<?= js('assets/js/navbar.js') ?>
|
||||
</body>
|
||||
|
||||
<?php
|
||||
snippet('footer') ?>
|
||||
@@ -1,30 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
Templates render the content of your pages.
|
||||
|
||||
They contain the markup together with some control structures
|
||||
like loops or if-statements. The `$page` variable always
|
||||
refers to the currently active page.
|
||||
|
||||
To fetch the content from each field we call the field name as a
|
||||
method on the `$page` object, e.g. `$page->title()`.
|
||||
|
||||
This default template must not be removed. It is used whenever Kirby
|
||||
cannot find a template with the name of the content file.
|
||||
|
||||
Snippets like the header and footer contain markup used in
|
||||
multiple templates. They also help to keep templates clean.
|
||||
|
||||
More about templates: https://getkirby.com/docs/guide/templates/basics
|
||||
*/
|
||||
|
||||
?>
|
||||
<?php
|
||||
snippet('header') ?>
|
||||
|
||||
<body class="font-sans antialiased bg-sf_grau-400 text-gray-900">
|
||||
<?php
|
||||
snippet('navbar') ?>
|
||||
<?php snippet('layout', slots: true) ?>
|
||||
|
||||
<section class="bg-sf_grau-50 py-24">
|
||||
<div class="lg:px-8 max-w-7xl mx-auto px-4 sm:px-6">
|
||||
@@ -53,8 +27,4 @@ snippet('navbar') ?>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<?= js('assets/js/navbar.js') ?>
|
||||
</body>
|
||||
|
||||
<?php
|
||||
snippet('footer') ?>
|
||||
<?php endsnippet() ?>
|
||||
|
||||
@@ -1,30 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
Templates render the content of your pages.
|
||||
|
||||
They contain the markup together with some control structures
|
||||
like loops or if-statements. The `$page` variable always
|
||||
refers to the currently active page.
|
||||
|
||||
To fetch the content from each field we call the field name as a
|
||||
method on the `$page` object, e.g. `$page->title()`.
|
||||
|
||||
This default template must not be removed. It is used whenever Kirby
|
||||
cannot find a template with the name of the content file.
|
||||
|
||||
Snippets like the header and footer contain markup used in
|
||||
multiple templates. They also help to keep templates clean.
|
||||
|
||||
More about templates: https://getkirby.com/docs/guide/templates/basics
|
||||
*/
|
||||
|
||||
?>
|
||||
<?php
|
||||
snippet('header') ?>
|
||||
|
||||
<body class="font-sans antialiased bg-sf_grau-400 text-gray-900">
|
||||
<?php
|
||||
snippet('navbar') ?>
|
||||
<?php snippet('layout', slots: true) ?>
|
||||
|
||||
<section class="bg-sf_grau-50 py-24">
|
||||
<div class="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8">
|
||||
@@ -156,8 +130,4 @@ snippet('navbar') ?>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<?= js('assets/js/navbar.js') ?>
|
||||
</body>
|
||||
|
||||
<?php
|
||||
snippet('footer') ?>
|
||||
<?php endsnippet() ?>
|
||||
@@ -1,39 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
Templates render the content of your pages.
|
||||
<?php snippet('layout', slots: true) ?>
|
||||
|
||||
They contain the markup together with some control structures
|
||||
like loops or if-statements. The `$page` variable always
|
||||
refers to the currently active page.
|
||||
<?php snippet('titel') ?>
|
||||
<?php snippet('termine') ?>
|
||||
|
||||
To fetch the content from each field we call the field name as a
|
||||
method on the `$page` object, e.g. `$page->title()`.
|
||||
|
||||
This default template must not be removed. It is used whenever Kirby
|
||||
cannot find a template with the name of the content file.
|
||||
|
||||
Snippets like the header and footer contain markup used in
|
||||
multiple templates. They also help to keep templates clean.
|
||||
|
||||
More about templates: https://getkirby.com/docs/guide/templates/basics
|
||||
*/
|
||||
|
||||
?>
|
||||
<?php
|
||||
snippet('header') ?>
|
||||
|
||||
<body>
|
||||
<?php
|
||||
snippet('navbar') ?>
|
||||
|
||||
<?php
|
||||
snippet('titel') ?>
|
||||
|
||||
<?php
|
||||
snippet('termine') ?>
|
||||
|
||||
<?= js('assets/js/navbar.js') ?>
|
||||
</body>
|
||||
|
||||
<?php
|
||||
snippet('footer') ?>
|
||||
<?php endsnippet() ?>
|
||||
Reference in New Issue
Block a user