From bd638c98bfb88c7e9f4024ce725762cebc46c7b2 Mon Sep 17 00:00:00 2001 From: Brij Mandaliya Date: Fri, 25 Oct 2024 12:40:22 +0530 Subject: [PATCH 1/2] Add: new function for set title for page and chapter page with book name in show page for both --- app/Entities/Controllers/ChapterController.php | 2 +- app/Entities/Controllers/PageController.php | 2 +- app/Http/Controller.php | 9 +++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/Entities/Controllers/ChapterController.php b/app/Entities/Controllers/ChapterController.php index 4274589e260..f38479f714e 100644 --- a/app/Entities/Controllers/ChapterController.php +++ b/app/Entities/Controllers/ChapterController.php @@ -84,7 +84,7 @@ public function show(string $bookSlug, string $chapterSlug) $nextPreviousLocator = new NextPreviousContentLocator($chapter, $sidebarTree); View::incrementFor($chapter); - $this->setPageTitle($chapter->getShortName()); + $this->setTitle($chapter->getShortName(), $chapter->book->getShortName()); return view('chapters.show', [ 'book' => $chapter->book, diff --git a/app/Entities/Controllers/PageController.php b/app/Entities/Controllers/PageController.php index eab53bb2510..fa0aedf429f 100644 --- a/app/Entities/Controllers/PageController.php +++ b/app/Entities/Controllers/PageController.php @@ -158,7 +158,7 @@ public function show(string $bookSlug, string $pageSlug) $nextPreviousLocator = new NextPreviousContentLocator($page, $sidebarTree); View::incrementFor($page); - $this->setPageTitle($page->getShortName()); + $this->setTitle($page->getShortName(), $page->book->getShortName()); return view('pages.show', [ 'page' => $page, diff --git a/app/Http/Controller.php b/app/Http/Controller.php index 8facf5dab3c..85befe89d77 100644 --- a/app/Http/Controller.php +++ b/app/Http/Controller.php @@ -45,6 +45,15 @@ public function setPageTitle(string $title) view()->share('pageTitle', $title); } + /** + * Adds the page title for chapter and page with book name into the view. + */ + public function setTitle(string $content, string $book) + { + $title = $book.' | '.$content; + view()->share('pageTitle', $title); + } + /** * On a permission error redirect to home and display. * the error as a notification. From 6c6edf6d991b09aba3e894f4953599075ba28c67 Mon Sep 17 00:00:00 2001 From: Brij Mandaliya Date: Fri, 25 Oct 2024 12:44:06 +0530 Subject: [PATCH 2/2] fix: lint PHP --- app/Http/Controller.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controller.php b/app/Http/Controller.php index 85befe89d77..85a452a0d52 100644 --- a/app/Http/Controller.php +++ b/app/Http/Controller.php @@ -50,7 +50,7 @@ public function setPageTitle(string $title) */ public function setTitle(string $content, string $book) { - $title = $book.' | '.$content; + $title = $book . ' | ' . $content; view()->share('pageTitle', $title); }