From d409d2baa2b06a6f2e13127277f03d2a1f3469c9 Mon Sep 17 00:00:00 2001 From: nikhil trivedi Date: Fri, 10 Jan 2025 14:14:37 -0600 Subject: [PATCH] Add page number to page title in authors and collections landing [WEB-2998] --- app/Http/Controllers/AuthorController.php | 7 +++++-- app/Http/Controllers/CollectionController.php | 11 +++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/AuthorController.php b/app/Http/Controllers/AuthorController.php index e175caf63e..68c598c07c 100644 --- a/app/Http/Controllers/AuthorController.php +++ b/app/Http/Controllers/AuthorController.php @@ -21,6 +21,11 @@ public function index(Request $request) $items = $this->repository->published()->ordered()->paginate(); $title = 'Authors'; + $titles = array_filter([ + $title, + request('page') ? 'Page ' . request('page') : null, + ]); + $this->seo->setTitle(implode(', ', $titles)); $subNav = [ ['label' => $title, 'href' => route('authors.index'), 'active' => true] @@ -30,8 +35,6 @@ public function index(Request $request) ['label' => 'Publications', 'href' => route('articles_publications'), 'links' => $subNav] ]; - $this->seo->setTitle($title); - $view_data = [ 'title' => $title, 'subNav' => $subNav, diff --git a/app/Http/Controllers/CollectionController.php b/app/Http/Controllers/CollectionController.php index 0c848ac783..714533e0d0 100644 --- a/app/Http/Controllers/CollectionController.php +++ b/app/Http/Controllers/CollectionController.php @@ -65,9 +65,16 @@ public function index() $activeFilters = $this->collection()->activeFilters(); if ($activeFilters->count()) { - $this->seo->setTitle(implode(', ', $activeFilters->pluck('label')->all())); + $titles = $activeFilters->pluck('label')->all(); + $titles[] = request('page') ? 'Page ' . request('page') : null; + $titles = array_filter($titles); + $this->seo->setTitle(implode(', ', $titles)); } else { - $this->seo->setTitle('Discover Art & Artists'); + $titles = array_filter([ + 'Discover Art & Artists', + request('page') ? 'Page ' . request('page') : null, + ]); + $this->seo->setTitle(implode(', ', $titles)); } if ($collection->count()) {