From bea35beb50fab0dbdf5fb92cdc25ace13cd38c96 Mon Sep 17 00:00:00 2001 From: Joe Carstairs Date: Sun, 18 May 2025 08:19:44 +0100 Subject: [PATCH] Note not found --- src/Controller/GuiController.php | 3 ++- templates/note.html.twig | 18 +++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/Controller/GuiController.php b/src/Controller/GuiController.php index 395b863..418e071 100644 --- a/src/Controller/GuiController.php +++ b/src/Controller/GuiController.php @@ -44,6 +44,7 @@ class GuiController extends AbstractController { 'title' => 'Joe Carstairs\' notes', 'description' => 'Joe Carstairs\' notes', 'note' => $note, + 'slug' => $slug, ]; } @@ -74,7 +75,7 @@ class GuiController extends AbstractController { $entityManager->persist($note); $entityManager->flush(); - return $this->redirectToRoute('note', ['slug' => $note->getSlug()]); + return $this->redirectToRoute('note', ['slug' => $slug]); } return $this->render('/write_note.html.twig', [ diff --git a/templates/note.html.twig b/templates/note.html.twig index 4cc29a3..0a47292 100644 --- a/templates/note.html.twig +++ b/templates/note.html.twig @@ -1,9 +1,17 @@ {% extends 'base.html.twig' %} {% block content %} -
-

Note

-
+ {% if note %} +
+

Note {{ note.slug }}

+
+ {% else %} +
+

Note not found

+

I don't have a note '{{ slug }}'.

+

Go back to Notes.

+
+ {% endif %} {% endblock %}