Quellcode durchsuchen

navbar template

twig
Ernest Debruyne vor 2 Jahren
Ursprung
Commit
d82e49c343
4 geänderte Dateien mit 27 neuen und 14 gelöschten Zeilen
  1. 1
    1
      public/index.php
  2. 6
    3
      templates/base.html.twig
  3. 11
    10
      templates/index.html.twig
  4. 9
    0
      templates/navbar.html.twig

+ 1
- 1
public/index.php Datei anzeigen

@@ -60,7 +60,7 @@ $app->get('/', function (Request $request, Response $response, array $args) {
global $twig;
$template = $twig->load('index.html.twig');
$a = $template->render(["key" => "value", "key2" => ["val1", "val2", "val3"], "name" => "John", "lastname" => "Doe"]);
$a = $template->render(["key" => "value", "key2" => ["val1", "val2", "val3"], "name" => "John", "lastname" => "Doe", "loggedIn" => isset($_SESSION['username'])]);
$response->getBody()->write($a);
// addNavbar($response);

+ 6
- 3
templates/base.html.twig Datei anzeigen

@@ -1,7 +1,10 @@
<html>
<body>
<div id="navbar">{% block navbar %} {% endblock %}</div>
<div id="main">{% block main %} {% endblock %}</div>
<div id="footer">{% block footer %} {% endblock %}</div>
<div id="navbar">
{% block navbar %} {% include "navbar.html.twig" %} {% endblock %}
</div>
<div id="messages">{% block messages %}{% endblock %}</div>
<diV id="main"> {% block main %}{% endblock %} </diV>
<div id="footer">{% block footer %}{% endblock %}</div>
</body>
</html>

+ 11
- 10
templates/index.html.twig Datei anzeigen

@@ -1,14 +1,15 @@
{% extends "base.html.twig" %} {% block main %}
<h1>

<h1>{{ key }}</h1>

<hr />
<ul>
{% for key in key2 %}
<li>{{ key }}</li>
{% endfor %}
</h1>
{% block navbar %} {% endblock %}
<form action="/">
<label for="name">First Name</label>
<input type="text" name="name" value="{{ name }}" /><br />
<label for="last-name">Last Name</label>
<input type="text" name="last-name" value="{{ lastname }}" />
</form>
{% endblock %} {% block footer %} Dit is de footer {% endblock %}

{{
key3.x1
}}
</ul>
{% endblock %} {% block footer %} Dit is de footer{% endblock %}

+ 9
- 0
templates/navbar.html.twig Datei anzeigen

@@ -0,0 +1,9 @@
<div><a href="/">Index</a> |
{% if loggedIn %}
<a href="/blog/create">Create Blog</a> |
<a href="/logout">Logout</a></div>
{% else %}
<a href="/login">Login</a></div>
{% endif %}

Laden…
Abbrechen
Speichern