Просмотр исходного кода

load blog contents dynamically, added css link

main
Ramdan Katakpawou 2 лет назад
Родитель
Сommit
ad02121478
1 измененных файлов: 6 добавлений и 4 удалений
  1. 6
    4
      public/index.php

+ 6
- 4
public/index.php Просмотреть файл

@@ -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;

Загрузка…
Отмена
Сохранить