Skip to content

Commit

Permalink
fix header
Browse files Browse the repository at this point in the history
  • Loading branch information
Smol-An committed Jan 21, 2024
1 parent 423419c commit 5c53eb6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
15 changes: 5 additions & 10 deletions public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,11 @@

$router = $app->getRouteCollector()->getRouteParser();

$app->get('/', function ($request, $response) use ($router) {
$params = ['router' => $router];
return $this->get('renderer')->render($response, 'home.phtml', $params);
$app->get('/', function ($request, $response) {
return $this->get('renderer')->render($response, 'home.phtml');
})->setName('home');

$app->get('/urls', function ($request, $response) use ($router) {
$app->get('/urls', function ($request, $response) {
$allUrlsData = $this->get('connection')
->query('SELECT id, name FROM urls ORDER BY id DESC')
->fetchAll(PDO::FETCH_ASSOC);
Expand All @@ -61,14 +60,11 @@
return $url;
}, $allUrlsData);

$params = [
'router' => $router,
'data' => $data
];
$params = ['data' => $data];
return $this->get('renderer')->render($response, 'urls/list.phtml', $params);
})->setName('urls');

$app->get('/urls/{id}', function ($request, $response, $args) use ($router) {
$app->get('/urls/{id}', function ($request, $response, $args) {
$id = $args['id'];
$flash = $this->get('flash')->getMessages();

Expand All @@ -91,7 +87,6 @@
$urlChecksData = $urlChecksStmt->fetchAll();

$params = [
'router' => $router,
'id' => $urlData['id'],
'name' => $urlData['name'],
'created_at' => $urlData['created_at'],
Expand Down
6 changes: 3 additions & 3 deletions templates/header.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@
<body>
<nav class="navbar navbar-expand-lg bg-dark ps-1" data-bs-theme="dark">
<div class="container-fluid">
<a class="navbar-brand" href="<?= $router->urlFor('home') ?>">Анализатор страниц</a>
<a class="navbar-brand" href="/">Анализатор страниц</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link" aria-current="page" href="<?= $router->urlFor('home') ?>">Главная</a>
<a class="nav-link" aria-current="page" href="/">Главная</a>
</li>
<li class="nav-item">
<a class="nav-link" href="<?= $router->urlFor('urls') ?>">Сайты</a>
<a class="nav-link" href="/urls">Сайты</a>
</li>
</ul>
</div>
Expand Down

0 comments on commit 5c53eb6

Please sign in to comment.