Explorar el Código

Navbar & Footer as Function

main
Lennart Verschelden hace 2 años
padre
commit
d567c80217
Se han modificado 1 ficheros con 16 adiciones y 10 borrados
  1. 16
    10
      public/index.php

+ 16
- 10
public/index.php Ver fichero

@@ -7,17 +7,21 @@ require __DIR__ . '/../vendor/autoload.php';

$app = AppFactory::create();

$app->get('/hello/{name}', function (Request $request, Response $response, array $args) {
$name = $args['name'];
$response->getBody()->write("Hello, $name");
return $response;
});
function addNavbar($response) {
$response->getBody()->write("<div><a href='/'>Index</a> | <a href='/login'>login</a></div>");
return;
}

function addFooter($response) {
$response->getBody()->write("<div>Privacy statement | Cookie Policy | Contact</div>");
return;
}

$app->get('/', function (Request $request, Response $response, array $args) {
$response->getBody()->write("<html><head></head><body>");
$response->getBody()->write("<div><a href='/'>Index</a> | <a href='/login'>login</a></div>");
addNavbar($response);
$response->getBody()->write("<hr/><h1>Onze blog</h1>");
$response->getBody()->write("<ul>");
@@ -27,15 +31,17 @@ $app->get('/', function (Request $request, Response $response, array $args) {
$response->getBody()->write("<li><a href='/blog/artikel-4'>Blogartikel 4</a></li>");
$response->getBody()->write("</ul>");
$response->getBody()->write("<hr/>");
$response->getBody()->write("<div>Privacy statement | Cookie Policy | Contact</div>");
$response->getBody()->write("");
addFooter($response);
$response->getBody()->write("</body></html>");
return $response;
});

$app->get('/blog/{slug}', function (Request $request, Response $response, array $args) {
$response->getBody()->write("Blog met slug");
$response->getBody()->write("<html><head></head><body>");
addNavbar($response);

addFooter($response);
return $response;
});


Cargando…
Cancelar
Guardar