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..85a452a0d52 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.