splitted twig templates in multiple files
This commit is contained in:
@@ -17,7 +17,7 @@ return function (App $app) {
|
|||||||
|
|
||||||
/** @var Twig $view */
|
/** @var Twig $view */
|
||||||
$view = $request->getAttribute('view');
|
$view = $request->getAttribute('view');
|
||||||
return $view->render($response, 'admin.twig', ['posts' => $posts]);
|
return $view->render($response, 'pages/admin.twig', ['posts' => $posts]);
|
||||||
});
|
});
|
||||||
|
|
||||||
// -------------------------------------------------
|
// -------------------------------------------------
|
||||||
@@ -46,7 +46,7 @@ return function (App $app) {
|
|||||||
/** @var Twig $view */
|
/** @var Twig $view */
|
||||||
$view = $request->getAttribute('view');
|
$view = $request->getAttribute('view');
|
||||||
|
|
||||||
return $view->render($response, 'post_form.twig', [
|
return $view->render($response, 'macros/post_form.twig', [
|
||||||
'action' => $id ? "/admin/edit/{$id}" : "/admin/create",
|
'action' => $id ? "/admin/edit/{$id}" : "/admin/create",
|
||||||
'post' => $post,
|
'post' => $post,
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -17,6 +17,6 @@ return function (App $app) {
|
|||||||
|
|
||||||
/** @var Twig $view */
|
/** @var Twig $view */
|
||||||
$view = $request->getAttribute('view'); // <-- récupération correcte
|
$view = $request->getAttribute('view'); // <-- récupération correcte
|
||||||
return $view->render($response, 'posts.twig', ['posts' => $posts]);
|
return $view->render($response, 'pages/posts.twig', ['posts' => $posts]);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>{% block title %}Mon Blog{% endblock %}</title>
|
<title>{% block title %}Mon Blog{% endblock %}</title>
|
||||||
|
{# <link rel="stylesheet" href="/css/main.css"> #}
|
||||||
<style>
|
<style>
|
||||||
body {font-family: Arial, sans-serif; margin: 2rem;}
|
body {font-family: Arial, sans-serif; margin: 2rem;}
|
||||||
.post {border-bottom: 1px solid #ccc; padding: 1rem 0;}
|
.post {border-bottom: 1px solid #ccc; padding: 1rem 0;}
|
||||||
@@ -11,11 +12,21 @@
|
|||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>
|
|
||||||
<a href="/">Mon Blog</a> |
|
|
||||||
<a href="/admin">Admin</a>
|
|
||||||
</h1>
|
|
||||||
{% block content %}{% endblock %}
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
||||||
|
{# Header commun #}
|
||||||
|
{% include 'partials/_header.twig' %}
|
||||||
|
|
||||||
|
|
||||||
|
{# Zone principale – chaque page injecte son contenu #}
|
||||||
|
<main>
|
||||||
|
{% block content %}{% endblock %}
|
||||||
|
</main>
|
||||||
|
|
||||||
|
{# Footer commun #}
|
||||||
|
{% include 'partials/_footer.twig' %}
|
||||||
|
|
||||||
|
|
||||||
|
{# Scripts globaux #}
|
||||||
|
<script src="/js/app.js"></script>
|
||||||
|
{% block scripts %}{% endblock %}</body>
|
||||||
|
</html>
|
||||||
|
|||||||
4
views/pages/home.twig
Normal file
4
views/pages/home.twig
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
{% extends "layout.twig" %}
|
||||||
|
{% block title %}Mon Blog{% endblock %}
|
||||||
|
{% block content %}
|
||||||
|
{% endblock %}
|
||||||
7
views/partials/_footer.twig
Normal file
7
views/partials/_footer.twig
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<footer class="site-footer">
|
||||||
|
<p>© {{ "now"|date("Y") }} Mon Blog – Tous droits réservés.</p>
|
||||||
|
<nav>
|
||||||
|
<a href="">À propos</a> |
|
||||||
|
<a href="">Contact</a>
|
||||||
|
</nav>
|
||||||
|
</footer>
|
||||||
6
views/partials/_header.twig
Normal file
6
views/partials/_header.twig
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<header>
|
||||||
|
<h1>
|
||||||
|
<a href="/">Mon Blog</a> |
|
||||||
|
<a href="/admin">Admin</a>
|
||||||
|
</h1>
|
||||||
|
</header>
|
||||||
Reference in New Issue
Block a user