From 4cff01c3a97fe3e6de8dbe0fd3f5eae042941972 Mon Sep 17 00:00:00 2001 From: Aleksei Miheev Date: Sun, 5 Jan 2014 13:48:50 +0000 Subject: [PATCH] Add canonical urls anywhere possible --- Sources/Display.php | 5 +++++ Themes/default/index.template.php | 3 +++ 2 files changed, 8 insertions(+) diff --git a/Sources/Display.php b/Sources/Display.php index 8397b56..1ba77e4 100644 --- a/Sources/Display.php +++ b/Sources/Display.php @@ -350,6 +350,11 @@ function Display() 'current_page' => $_REQUEST['start'] / $modSettings['defaultMaxMessages'] + 1, 'num_pages' => floor($topicinfo['numReplies'] / $modSettings['defaultMaxMessages']) + 1 ); + if (isset ($_REQUEST['topicname'])) { + $context['canonical_url'] = "/forum/{$_REQUEST['topicname']}?start={$_REQUEST['start']}"; + } else { + $context['canonical_url'] = $scripturl . '?topic=' . $topic . '.' . $_REQUEST['start']; + } // Figure out all the link to the next/prev/first/last/etc. for wireless mainly. $context['links'] = array( diff --git a/Themes/default/index.template.php b/Themes/default/index.template.php index 534f87a..04f791d 100644 --- a/Themes/default/index.template.php +++ b/Themes/default/index.template.php @@ -94,6 +94,9 @@ function template_main_above() '; + if (!empty($context['canonical_url'])) + echo ' + '; // If we're in a board, or a topic for that matter, the index will be the board's index. if (!empty($context['current_board'])) {