Browse Source

load blog contents dynamically, added css link

main
Ramdan Katakpawou 2 years ago
parent
commit
ad02121478
1 changed files with 6 additions and 4 deletions
  1. 6
    4
      public/index.php

+ 6
- 4
public/index.php View File

@@ -11,7 +11,7 @@ $app = AppFactory::create();
function addNavBar($response)
{

$response->getBody()->write("<html><head></head><body>");
$response->getBody()->write('<html><head><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/water.css"></head><body>');
if (isset($_SESSION['username'])) {
$response->getBody()->write('<div><a href="/">Index</a> | <a href="/blog/create">Create Blog</a> | <a href="/logout">Logout</a></div>');
} else {
@@ -63,9 +63,11 @@ $app->get('/', function (Request $request, Response $response, array $args) {
$app->get('/blog/{slug}', function (Request $request, Response $response, array $args) {

addNavBar($response);
$title= $args['slug'];
$response->getBody()->write("<h1>$title</h1>");

foreach ($_SESSION['blogs'] as $art) {
if ($art['slug'] == $args['slug']) {
$response->getBody()->write("<h1>" . $art['title'] . "</h1>");
}
}
addFooter($response);

return $response;

Loading…
Cancel
Save