From 9fa8fab864e53f3db3ca3ac6c22357e7c3e9d5dc Mon Sep 17 00:00:00 2001 From: Andreas Date: Mon, 24 Aug 2015 12:39:13 +0200 Subject: [PATCH] "404" and "404-search" rendered within layout! Before this pull request, the 404 and 404-search templates where handled as full HTML pages without the page context (layout). With this pull request both pages are rendered inside the selected themes layout. Additionally the 404 template now contains the "search form" and the homepage link. All Themes are already updated with the above changes. --- system/admin/views/layout.html.php | 4 +++- system/htmly.php | 16 +++++++++++----- system/includes/functions.php | 16 ++++++++-------- themes/blog/404-search.html.php | 35 +++++++++++++++-------------------- themes/blog/404.html.php | 32 ++++++++++++++------------------ themes/blog/layout.html.php | 4 +++- themes/clean/404-search.html.php | 29 ++++++++++------------------- themes/clean/404.html.php | 28 ++++++++++------------------ themes/clean/layout.html.php | 4 +++- themes/default/404-search.html.php | 29 ++++++++++------------------- themes/default/404.html.php | 28 ++++++++++------------------ themes/default/css/style.css | 7 ++++++- themes/default/layout.html.php | 4 +++- themes/logs/404-search.html.php | 29 ++++++++++------------------- themes/logs/404.html.php | 28 ++++++++++------------------ themes/logs/css/style.css | 4 ++++ themes/logs/layout.html.php | 4 +++- 17 files changed, 133 insertions(+), 168 deletions(-) diff --git a/system/admin/views/layout.html.php b/system/admin/views/layout.html.php index 4a92e17..f467c5a 100644 --- a/system/admin/views/layout.html.php +++ b/system/admin/views/layout.html.php @@ -4,7 +4,9 @@ <?php echo $title;?> - + + + diff --git a/system/htmly.php b/system/htmly.php index 73e4cbb..30e52e2 100644 --- a/system/htmly.php +++ b/system/htmly.php @@ -1301,14 +1301,20 @@ get('/search/:keyword', function ($keyword) { $posts = get_keyword($keyword, $page, $perpage); - $total = keyword_count($keyword); - - if (empty($posts) || $page < 1) { - // a non-existing page - render('404-search', null, false); + if (!$posts || $page < 1) { + // a non-existing page or no search result + render('404-search', array( + 'title' => 'Search results not found! - ' . blog_title(), + 'description' => '', + 'breadcrumb' => '' . config('breadcrumb.home') . ' » No search results', + 'canonical' => site_url() . 'search/' . strtolower($keyword), + 'bodyclass' => 'error-404-search', + )); die; } + $total = keyword_count($keyword); + render('main', array( 'title' => 'Search results for: ' . tag_i18n($keyword) . ' - ' . blog_title(), 'description' => 'Search results for: ' . tag_i18n($keyword) . ' on ' . blog_title() . '.', diff --git a/system/includes/functions.php b/system/includes/functions.php index c20a0c3..928f4d4 100644 --- a/system/includes/functions.php +++ b/system/includes/functions.php @@ -654,13 +654,7 @@ function get_keyword($keyword, $page, $perpage) } } - if (empty($tmp)) { - // a non-existing page - render('404-search', null, false); - die; - } - - return $tmp = get_posts($tmp, $page, $perpage); + return ($tmp) ? get_posts($tmp, $page, $perpage) : []; } // Get related posts base on post tag. @@ -1543,7 +1537,13 @@ EOF; function not_found() { header($_SERVER["SERVER_PROTOCOL"] . " 404 Not Found"); - render('404', null, false); + render('404', array( + 'title' => 'This page doesn\'t exist! - ' . blog_title(), + 'description' => '', + 'canonical' => false, + 'breadcrumb' => '' . config('breadcrumb.home') . ' » 404 Not Found', + 'bodyclass' => 'error-404', + )); die(); } diff --git a/themes/blog/404-search.html.php b/themes/blog/404-search.html.php index 041f867..c7b1972 100644 --- a/themes/blog/404-search.html.php +++ b/themes/blog/404-search.html.php @@ -1,21 +1,16 @@ - - - - - - - - Search results not found! - <?php echo blog_title() ?> - - - - -
-

Search results not found!

-
- + + + +
+
+
+
+

Search results not found!

+

Please search again, or would you like to try our homepage instead?

+
+ +
+
+
-

Please search again, or would you like to try our homepage instead?

-
- - \ No newline at end of file + diff --git a/themes/blog/404.html.php b/themes/blog/404.html.php index cf762e1..2f495ce 100644 --- a/themes/blog/404.html.php +++ b/themes/blog/404.html.php @@ -1,18 +1,14 @@ - - - - - - - - 404 Not Found - <?php echo blog_title() ?> - - - - -
-

This page doesn't exist!

-

Would you like to try our homepage instead?

-
- - \ No newline at end of file + + + +
+
+
+
+

This page doesn't exist!

+

Please search to find what you're looking for or visit our homepage instead.

+ +
+
+
+
\ No newline at end of file diff --git a/themes/blog/layout.html.php b/themes/blog/layout.html.php index d2ca1b9..4b8dd74 100644 --- a/themes/blog/layout.html.php +++ b/themes/blog/layout.html.php @@ -6,7 +6,9 @@ <?php echo $title;?> - + + + diff --git a/themes/clean/404-search.html.php b/themes/clean/404-search.html.php index 2c2485c..ce5ebff 100644 --- a/themes/clean/404-search.html.php +++ b/themes/clean/404-search.html.php @@ -1,21 +1,12 @@ - - - - - - - - Search results not found! - <?php echo blog_title() ?> - - - - -
-

Search results not found!

-